[1/3] debugging with yama: move make_cleanup_fclose
Commit Message
Hi.
This patch just moves make_cleanup_fclose to a common place.
[IWBN if we did not have to keep doing this piecemeal.]
2015-09-28 Doug Evans <dje@google.com>
* common/filestuff.c (do_fclose_cleanup, make_cleanup_fclose): Move
here ...
* utils.c: ... from here.
* common/filestuff.h (do_fclose_cleanup, make_cleanup_fclose): Move
here ...
* utils.h: ... from here.
@@ -425,3 +425,21 @@ make_cleanup_close (int fd)
*saved_fd = fd;
return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
}
+
+/* Helper function which does the work for make_cleanup_fclose. */
+
+static void
+do_fclose_cleanup (void *arg)
+{
+ FILE *file = (FILE *) arg;
+
+ fclose (file);
+}
+
+/* See filestuff.h. */
+
+struct cleanup *
+make_cleanup_fclose (FILE *file)
+{
+ return make_cleanup (do_fclose_cleanup, file);
+}
@@ -71,4 +71,8 @@ extern int gdb_pipe_cloexec (int filedes[2]);
extern struct cleanup *make_cleanup_close (int fd);
+/* Return a new cleanup that closes FILE. */
+
+extern struct cleanup *make_cleanup_fclose (FILE *file);
+
#endif /* FILESTUFF_H */
@@ -191,24 +191,6 @@ make_cleanup_bfd_unref (bfd *abfd)
return make_cleanup (do_bfd_close_cleanup, abfd);
}
-/* Helper function which does the work for make_cleanup_fclose. */
-
-static void
-do_fclose_cleanup (void *arg)
-{
- FILE *file = (FILE *) arg;
-
- fclose (file);
-}
-
-/* Return a new cleanup that closes FILE. */
-
-struct cleanup *
-make_cleanup_fclose (FILE *file)
-{
- return make_cleanup (do_fclose_cleanup, file);
-}
-
/* Helper function which does the work for make_cleanup_obstack_free. */
static void
@@ -78,10 +78,6 @@ struct section_addr_info;
extern struct cleanup *(make_cleanup_free_section_addr_info
(struct section_addr_info *));
-/* For make_cleanup_close see common/filestuff.h. */
-
-extern struct cleanup *make_cleanup_fclose (FILE *file);
-
extern struct cleanup *make_cleanup_bfd_unref (bfd *abfd);
struct obstack;