[PATCH 1/2] Introduce obstack_new, poison other "typed" obstack functions
Tom Tromey
tom@tromey.com
Wed Apr 25 22:36:00 GMT 2018
>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
Simon> This patch introduces a utility to make this pattern simpler:
Simon> foo *f = obstack_new<foo> ();
What about just having those types that can use this inherit from
allocate_on_obstack? Then you can write:
foo *f = new (obstack) foo ();
It would be nice if we could have a global operator new that does this,
but I don't think it is possible to have one that is limited to
is_trivially_constructible classes.
Maybe is_trivially_destructible is also needed somehow since an obstack
isn't going to run those destructors. Not sure how to manage this
either, right now allocate_on_obstack just assumes you know what you're
up to.
Simon> To help catch places where we would forget to call new when allocating
Simon> such an object on an obstack, this patch also poisons some other methods
Simon> of allocating an instance of a type on an obstack:
This is excellent.
Tom
More information about the Gdb-patches
mailing list