From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simon.marchi@ericsson.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] Introduce obstack_new, poison other "typed" obstack functions
Date: Wed, 25 Apr 2018 22:36:00 -0000 [thread overview]
Message-ID: <87sh7i7w2i.fsf@tromey.com> (raw)
In-Reply-To: <1524685183-5553-1-git-send-email-simon.marchi@ericsson.com> (Simon Marchi's message of "Wed, 25 Apr 2018 15:39:42 -0400")
>>>>> "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
next prev parent reply other threads:[~2018-04-25 22:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-25 19:40 Simon Marchi
2018-04-25 19:40 ` [PATCH 2/2] Use XOBNEW when possible Simon Marchi
2018-04-25 22:27 ` Tom Tromey
2018-04-26 2:59 ` Simon Marchi
2018-04-25 22:36 ` Tom Tromey [this message]
2018-04-26 2:58 ` [PATCH 1/2] Introduce obstack_new, poison other "typed" obstack functions Simon Marchi
2018-04-26 17:42 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sh7i7w2i.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).