This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix using_directive memory leak pr 11236


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]