Re: [PATCH] cex: fix leaks
Akim Demaille <[email protected]>
| Newsgroups | gmane.comp.parsers.bison.patches |
|---|---|
| Message-ID | <[email protected]> |
> Le 17 mai 2020 à 16:31, Akim Demaille <[email protected]> a écrit : > > Your patch improves things: we go from > > SUMMARY: AddressSanitizer: 262960 byte(s) leaked in 1874 allocation(s). > > to > > SUMMARY: AddressSanitizer: 187064 byte(s) leaked in 779 allocation(s). > > The following commit reduces it further to > > SUMMARY: AddressSanitizer: 184968 byte(s) leaked in 648 allocation(s). The following one reaches SUMMARY: AddressSanitizer: 11352 byte(s) leaked in 263 allocation(s). after addressing a very simple mistake. commit a27143632de930f0ceea7fb7ff4d0cc492cf4c9d Author: Akim Demaille <[email protected]> Date: Sun May 17 16:41:51 2020 +0200 cex: properly reclaim hash's allocated memory * src/state-item.c: Use hash_free where appropriate. diff --git a/src/state-item.c b/src/state-item.c index bcb21102..76c0b4f2 100644 --- a/src/state-item.c +++ b/src/state-item.c @@ -77,7 +77,7 @@ hash_pair_lookup (Hash_table *tab, int key) static void hash_pair_insert (Hash_table *tab, int key, bitset val) { - hash_pair *hp = xmalloc (sizeof (hash_pair)); + hash_pair *hp = xmalloc (sizeof *hp); hp->key = key; hp->l = val; hash_pair *res = hash_xinsert (tab, hp); @@ -234,7 +234,7 @@ init_trans (void) } } } - free (transition_set); + hash_free (transition_set); } } @@ -304,7 +304,7 @@ init_prods (void) bitset_set (si_revs[prod], j); } } - free (closure_map); + hash_free (closure_map); } }