aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdb_obstack.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdb_obstack.h')
-rw-r--r--gdb/gdb_obstack.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
index 12a90c3..1011008 100644
--- a/gdb/gdb_obstack.h
+++ b/gdb/gdb_obstack.h
@@ -78,4 +78,24 @@ struct auto_obstack : obstack
{ obstack_free (this, obstack_base (this)); }
};
+/* Objects are allocated on obstack instead of heap. */
+
+struct allocate_on_obstack
+{
+ allocate_on_obstack () = default;
+
+ void* operator new (size_t size, struct obstack *obstack)
+ {
+ return obstack_alloc (obstack, size);
+ }
+
+ void* operator new[] (size_t size, struct obstack *obstack)
+ {
+ return obstack_alloc (obstack, size);
+ }
+
+ void operator delete (void *memory) {}
+ void operator delete[] (void *memory) {}
+};
+
#endif