This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOC
>>>>> "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