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 #PR 25933] memory leaks


Uttam Pawar <uttamp@us.ibm.com> writes:

> diff -urpN trunk.orig/gcc/tree-ssa-live.c trunk/gcc/tree-ssa-live.c
> --- trunk.orig/gcc/tree-ssa-live.c      2006-01-18 10:03:20.000000000 -0800
> +++ trunk/gcc/tree-ssa-live.c   2006-01-24 10:01:53.000000000 -0800
> @@ -1079,11 +1079,15 @@ type_var_init (var_map map)
>    sbitmap seen;
> 
>    seen = sbitmap_alloc (num_partitions);
> -  sbitmap_zero (seen);
> 
>    tv = tpa_init (map);
>    if (!tv)
> -    return NULL;
> +    {
> +      sbitmap_free (seen);
> +      return NULL;
> +    }
> +
> +  sbitmap_zero (seen);
> 
>    for (x = num_partitions - 1; x >= 0; x--)
>      {

Well, I was trying to suggest that you also move the sbitmap_alloc
call until after the call to tpa_init.  Then you don't have to do
anything special if tpa_init fails--you can just return NULL as the
code currently does.

The patch is OK with that change.

Thanks.

Ian


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