OSDN Git Service

* utils.c (do_obstack_free): New function.
authortromey <tromey>
Thu, 19 Mar 2009 17:39:30 +0000 (17:39 +0000)
committertromey <tromey>
Thu, 19 Mar 2009 17:39:30 +0000 (17:39 +0000)
(make_cleanup_obstack_free): Likewise.
* defs.h (make_cleanup_obstack_free): Declare.

gdb/ChangeLog
gdb/defs.h
gdb/utils.c

index b96ecc3..107396e 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2009-03-18  Doug Evans  <dje@google.com>
 
        * linux-nat.c (linux_nat_find_memory_regions): Result of PIDGET is an
index 001db81..e140474 100644 (file)
@@ -366,6 +366,9 @@ extern struct cleanup *make_cleanup_fclose (FILE *file);
 
 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 9224839..0becfd9 100644 (file)
@@ -271,6 +271,23 @@ 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
+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)
 {