From: Wei-min Pan <weimin.pan@oracle.com>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: CTF support
Date: Thu, 03 Oct 2019 18:21:00 -0000 [thread overview]
Message-ID: <d2c5f8f5-f39c-4b08-5970-c50f8eda683f@oracle.com> (raw)
In-Reply-To: <75851ff5-771d-16fb-0a74-661c9e0722d3@simark.ca>
On 10/3/2019 11:01 AM, Simon Marchi wrote:
> On 2019-10-03 1:58 p.m., Wei-min Pan wrote:
>> But the `free` call is needed to free up space allocated by libctf's
ctf_type_aname_raw.
>
> That's the point of gdb::unique_xmalloc_pointer: it will
automatically call xfree (free) when
> on scope exit, free'ing this copy. It's preferred to use this
instead of manually calling
> xfree, because it makes it harder to forget to free the memory (or to
free it twice).
Let's use an example (checking omitted):
We're replacing:
 name = ctf_type_aname_raw (fp, tid);
 TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name);
 free (name);
with
 gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (fp, tid));
 TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ());
The allocated copy from ctf_type_aname_raw is not freed. Or did I miss
something?
Weimin
next prev parent reply other threads:[~2019-10-03 18:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 23:45 Weimin Pan
2019-09-21 22:21 ` Simon Marchi
2019-09-23 21:11 ` Weimin Pan
2019-09-24 3:10 ` Simon Marchi
2019-09-25 0:22 ` Weimin Pan
2019-09-25 0:27 ` Simon Marchi
2019-09-25 2:04 ` Wei-min Pan
2019-09-25 2:35 ` Simon Marchi
2019-09-25 21:09 ` Wei-min Pan
2019-09-30 3:06 ` Simon Marchi
2019-10-01 0:37 ` Weimin Pan
2019-10-02 2:47 ` Simon Marchi
2019-10-02 23:10 ` Wei-min Pan
2019-10-03 12:40 ` Simon Marchi
2019-10-03 17:59 ` Wei-min Pan
2019-10-03 18:01 ` Simon Marchi
2019-10-03 18:21 ` Wei-min Pan [this message]
2019-10-03 18:31 ` Simon Marchi
2019-10-03 18:53 ` Wei-min Pan
2019-10-03 20:33 ` Wei-min Pan
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=d2c5f8f5-f39c-4b08-5970-c50f8eda683f@oracle.com \
--to=weimin.pan@oracle.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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