From acab739b55824f508dd61de9ab8ef91c18b1a086 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 7 Jun 2023 23:31:47 +0200 Subject: Further fixes of substitution and use-after-free --- src/map.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/map.c') diff --git a/src/map.c b/src/map.c index c36354d..553bbde 100644 --- a/src/map.c +++ b/src/map.c @@ -13,7 +13,7 @@ static struct hashmap *all_terms; static void hashmap_free_term(void *item) { struct term *term = *(struct term **)item; - term_destroy_head(term); + term_destroy_head(term, 1); } struct hashmap *map_all_terms(void) @@ -51,14 +51,19 @@ void map_destroy(struct hashmap *map) hashmap_free(map); } -void map_dump(struct hashmap *map) +void map_dump(struct hashmap *map, char all) { fprintf(stderr, "\n---\nMap dump:\n"); + fprintf(stderr, "type\trefs\thash\t\t\tterm\t\tparents\n"); size_t iter = 0; void *iter_val; while (hashmap_iter(map, &iter, &iter_val)) { struct term *term = *(struct term **)iter_val; - fprintf(stderr, "%d\t%ld\t", term->type, term->refs); + /* if (!all && !term->is_program) */ + /* continue; */ + + fprintf(stderr, "%d\t%ld\t%lx\t", term->type, term->refs, + term->hash); term_print(term); fprintf(stderr, "\t{"); -- cgit v1.2.3