[PATCH] Free memory in et-forest
Ian Lance Taylor
iant@google.com
Mon Jun 19 20:37:00 GMT 2006
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
More information about the Gcc-patches
mailing list