diff options
Diffstat (limited to 'gdb/gdb_obstack.h')
-rw-r--r-- | gdb/gdb_obstack.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h index 3f34d96ed0c..b241c8274f1 100644 --- a/gdb/gdb_obstack.h +++ b/gdb/gdb_obstack.h @@ -63,4 +63,19 @@ extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL; extern char *obstack_strdup (struct obstack *obstackp, const char *string); +/* An obstack that frees itself on scope exit. */ +struct auto_obstack : obstack +{ + auto_obstack () + { obstack_init (this); } + + ~auto_obstack () + { obstack_free (this, NULL); } + + /* Free all memory in the obstack but leave it valid for further + allocation. */ + void clear () + { obstack_free (this, obstack_base (this)); } +}; + #endif |