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] Free memory in et-forest


Richard Guenther <rguenther@suse.de> writes:

> 2006-06-15  Michael Matz  <matz@suse.de>
> 	Richard Guenther  <rguenther@suse.de>
> 
> 	* et-forest.c (et_free_tree_force): Correctly free the
> 	et-forest pools.
> 
> Index: et-forest.c
> ===================================================================
> --- et-forest.c	(Revision 114599)
> +++ et-forest.c	(Arbeitskopie)
> @@ -505,7 +505,19 @@ void
>  et_free_tree_force (struct et_node *t)
>  {
>    pool_free (et_occurrences, t->rightmost_occ);
> +  if (t->parent_occ)
> +    pool_free (et_occurrences, t->parent_occ);
> +  if (et_occurrences->elts_free == et_occurrences->elts_allocated)
> +    {
> +      free_alloc_pool (et_occurrences);
> +      et_occurrences = NULL;
> +    }
>    pool_free (et_nodes, t);
> +  if (et_nodes->elts_free == et_nodes->elts_allocated)
> +    {
> +      free_alloc_pool (et_nodes);
> +      et_nodes = NULL;
> +    }
>  }
>  
>  /* Sets father of et tree T to FATHER.  */

I think it would be better to remove the two instances of elts_free ==
elts_allocated.  Those are currently private variables of
alloc-pool.c.  Instead, add a new function to alloc-pool.c to check
for that, something like
    void free_alloc_pool_if_empty (alloc_pool *arg);
which sets *ARG to NULL if it is freed.

Then add a function
    et_free_pools (void)
which calls that on both pools, and then call that from
free_dominance_info, instead of checking each time through
et_free_tree_force.

At least, I think that would be a little bit cleaner and a little bit
easier to maintain.  But feel free to disagree.

If you like those changes, then patch is approved with those changes
after bootstrap and testing.

:REVIEWMAIL:

Ian


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