From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOC
Date: Thu, 13 Sep 2018 03:31:00 -0000 [thread overview]
Message-ID: <87r2hyhy41.fsf@tromey.com> (raw)
In-Reply-To: <20180913003018.GB5952@embecosm.com> (Andrew Burgess's message of "Thu, 13 Sep 2018 01:30:19 +0100")
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
>> Would you mind seeing what happens if you use obstack_zalloc here
>> instead? It seems like that would give us some extra compile-time
>> safety. If it fails, that would be interesting.
Andrew> Unless I'm missing something (very possible) there's no suitable
Andrew> obstack_zalloc to use here.
Yeah, you're right, thanks for looking.
Andrew> - TYPE_FIELDS (new_type) = XCNEWVEC (struct field, nfields);
Andrew> + TYPE_FIELDS (new_type) = (struct field *)
Andrew> + TYPE_ALLOC (new_type, nfields * sizeof (struct field));
XCNEWVEC clears the memory so I think this should be TYPE_ZALLOC.
This is ok with this change.
thanks,
Tom
prev parent reply other threads:[~2018-09-13 3:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 14:12 Andrew Burgess
2018-09-11 20:38 ` Tom Tromey
2018-09-13 0:31 ` Andrew Burgess
2018-09-13 3:31 ` Tom Tromey [this message]
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=87r2hyhy41.fsf@tromey.com \
--to=tom@tromey.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/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