This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: add an obstack cleanup


I'm checking this in.

This patch adds a function to create a cleanup that frees an obstack.
I'm splitting up the charset patch for checkin, and this is the first
(and smallest) piece.

Tom

2009-03-19  Tom Tromey  <tromey@redhat.com>

	* utils.c (do_obstack_free): New function.
	(make_cleanup_obstack_free): Likewise.
	* defs.h (make_cleanup_obstack_free): Declare.

Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.246
diff -u -r1.246 defs.h
--- defs.h	13 Mar 2009 02:34:13 -0000	1.246
+++ defs.h	19 Mar 2009 17:32:54 -0000
@@ -366,6 +366,9 @@
 
 extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
 
+struct obstack;
+extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
+
 extern struct cleanup *make_cleanup_restore_integer (int *variable);
 
 extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.206
diff -u -r1.206 utils.c
--- utils.c	21 Feb 2009 16:14:49 -0000	1.206
+++ utils.c	19 Mar 2009 17:32:55 -0000
@@ -271,6 +271,23 @@
   return make_cleanup (do_fclose_cleanup, file);
 }
 
+/* Helper function which does the work for make_cleanup_obstack_free.  */
+
+static void
+do_obstack_free (void *arg)
+{
+  struct obstack *ob = arg;
+  obstack_free (ob, NULL);
+}
+
+/* Return a new cleanup that frees OBSTACK.  */
+
+struct cleanup *
+make_cleanup_obstack_free (struct obstack *obstack)
+{
+  return make_cleanup (do_obstack_free, obstack);
+}
+
 static void
 do_ui_file_delete (void *arg)
 {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]