This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2] Introduce obstack_new, poison other "typed" obstack functions
- From: Tom Tromey <tom at tromey dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Wed, 25 Apr 2018 16:36:21 -0600
- Subject: Re: [PATCH 1/2] Introduce obstack_new, poison other "typed" obstack functions
- References: <1524685183-5553-1-git-send-email-simon.marchi@ericsson.com>
>>>>> "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