From ccd4914d395b5a588868cffaad580c29167e6747 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 1 Jun 2023 16:14:34 +0200 Subject: More parenting --- src/map.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/map.c') diff --git a/src/map.c b/src/map.c index 57394ee..16518e2 100644 --- a/src/map.c +++ b/src/map.c @@ -28,9 +28,9 @@ struct term *map_get(struct hashmap *map, hash_t hash) return *handle; } -void map_set(struct hashmap *map, struct term *term, hash_t hash) +void map_set(struct hashmap *map, struct term *term) { - hashmap_set(map, &term, hash); + hashmap_set(map, &term, term->hash); } void map_initialize(void) @@ -55,9 +55,18 @@ void map_dump(struct hashmap *map) void *iter_val; while (hashmap_iter(map, &iter, &iter_val)) { struct term *term = *(struct term **)iter_val; - fprintf(stderr, "%d ", term->type); + fprintf(stderr, "%d\t%ld\t", term->type, term->refs); term_print(term); - fprintf(stderr, " %ld\n", term->refs); + fprintf(stderr, "\t{"); + + size_t jiter = 0; + void *jiter_val; + while (hashmap_iter(term->parents, &jiter, &jiter_val)) { + struct term *parent = *(struct term **)jiter_val; + term_print(parent); + fprintf(stderr, ", "); + } + fprintf(stderr, "}\n"); } fprintf(stderr, "---\n\n"); } -- cgit v1.2.3