This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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 04/N] Fix big memory leak in ix86_valid_target_attribute_p


On 11/12/2015 12:33 PM, Bernd Schmidt wrote:
> On 11/12/2015 12:29 PM, Richard Biener wrote:
>> +static bool opts_obstack_initialized = false;
>> +
>> +/* Initialize opts_obstack if not initialized.  */
>> +
>> +void
>> +init_opts_obstack (void)
>> +{
>> +  if (!opts_obstack_initialized)
>> +    {
>> +      opts_obstack_initialized = true;
>> +      gcc_obstack_init (&opts_obstack);
>>
>> you can move the static global to function scope.
> 
> Also, why bother with it? Why not simply arrange to call the function just once at startup?

Hello.

It's called from multiple locations:

$ git grep init_opts_obstack
gcc/gcc.c:  init_opts_obstack ();
gcc/lto-wrapper.c:  init_opts_obstack ();
gcc/opts.c:init_opts_obstack (void)
gcc/opts.c:  init_opts_obstack ();
gcc/opts.h:extern void init_opts_obstack (void);

Maybe there's a common ancestor of all paths, maybe it can be done as a follow-up.

> 
> It's not clear from the submission why this is done and how it relates to the i386.c hunk.

Sorry that the hunk isn't explained better, in fast this change is unrelated and fixed
another memory leak.

Thanks,
Martin

> 
> 
> Bernd


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