This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/3] debugging with yama: move make_cleanup_fclose
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 28 Sep 2015 19:24:44 +0000
- Subject: [PATCH 1/3] debugging with yama: move make_cleanup_fclose
- Authentication-results: sourceware.org; auth=none
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.
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
index 798a411..b08f259 100644
--- a/gdb/common/filestuff.c
+++ b/gdb/common/filestuff.c
@@ -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);
+}
diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h
index e997ecc..96f9e65 100644
--- a/gdb/common/filestuff.h
+++ b/gdb/common/filestuff.h
@@ -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 */
diff --git a/gdb/utils.c b/gdb/utils.c
index c7f00d9..a6b5744 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -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
diff --git a/gdb/utils.h b/gdb/utils.h
index 995a1cf..d1111fa 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -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;