Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] New class allocate_on_obstack
Date: Wed, 07 Feb 2018 17:35:00 -0000	[thread overview]
Message-ID: <CAH=s-PPtTkeUhKDmF_dY+x33KYs0fP9HP+58apEdKq+eQyGwvw@mail.gmail.com> (raw)
In-Reply-To: <874lmsyg0f.fsf@tromey.com>

On Wed, Feb 7, 2018 at 3:29 PM, Tom Tromey <tom@tromey.com> wrote:
>>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> writes:
>
> Yao> This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile
> Yao> inherit it, so that dwarf2_per_objfile is automatically allocated on
> Yao> obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space.
>
> I still think it should be restricted to types with a trivial
> destructor.  Otherwise, someday, the lack of actual destruction is going
> to cause a bug.
>

Can you give me some clues on how to do the restriction?  I think I need to
use std::enable_if and std::is_trivially_destructible, but don't know how to put
them into the code.

Lack of destruction causes a bug in any case.  If object is allocated on heap,
and don't do "delete p", the dtor isn't called and memory is leaked.  I
expect use "delete p" no matter where the object is allocated (on heap or
on obstack).

-- 
Yao (齐尧)


  reply	other threads:[~2018-02-07 17:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07  9:40 Yao Qi
2018-02-07 15:20 ` Pedro Alves
2018-02-07 15:29 ` Tom Tromey
2018-02-07 17:35   ` Yao Qi [this message]
2018-02-08 20:58     ` Yao Qi
2018-02-16 16:22 ` Yao Qi

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='CAH=s-PPtTkeUhKDmF_dY+x33KYs0fP9HP+58apEdKq+eQyGwvw@mail.gmail.com' \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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