This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix using_directive memory leak pr 11236
- From: Tom Tromey <tromey at redhat dot com>
- To: Sami Wagiaalla <swagiaal at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Wed, 03 Mar 2010 14:48:46 -0700
- Subject: Re: [patch] Fix using_directive memory leak pr 11236
- References: <4B8ECACA.9010504@redhat.com>
- Reply-to: tromey at redhat dot com
>>>>> "Sami" == Sami Wagiaalla <swagiaal@redhat.com> writes:
Sami> PR C++/11236:
Sami> * cp-namespace.c (cp_add_using): Deleted.
Sami> (cp_add_using_directive): Use obstack allocations.
Sami> Merged the function cp_add_using into this one.
Sami> Added 'struct obstack *' argument.
Sami> (cp_scan_for_anonymous_namespaces): Updated.
Sami> * cp-support.h: Updated.
Sami> * dwarf2read.c (read_import_statement): Updated.
Sami> (read_namespace): Updated.
Sami> (new_symbol): Updated.
Sami> * stabsread.c (define_symbol): Updated.
Thanks for doing this.
This general idea is fine, but I have a few comments.
Sami> -cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
Sami> +cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
Sami> + struct obstack *obstack)
I don't think you need a new argument here.
Instead, I think you can use SYMBOL_SYMTAB (symbol)->obstack.
Sami> if (strcmp (current->import_src, src) == 0
Sami> - && strcmp (current->import_dest, dest) == 0)
Sami> + && strcmp (current->import_dest, dest) == 0
Sami> + && alias && strcmp (current->alias, alias) == 0)
This logic is incorrect if current->alias == NULL.
Sami> + new = obstack_alloc (obstack, sizeof (struct using_direct));
Sami> + memset (new, 0, sizeof (struct using_direct));
Use OBSTACK_ZALLOC here.
thanks,
Tom