From 5694883ef55f745ef5d81706347c815965dade4a Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Sat, 1 Oct 2022 19:07:05 +0200 Subject: [PATCH] 2019 day 6: remove count of allocated tries/objects --- 2019/day06/aoc-c.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/2019/day06/aoc-c.c b/2019/day06/aoc-c.c index 54e7a2f..3633029 100644 --- a/2019/day06/aoc-c.c +++ b/2019/day06/aoc-c.c @@ -122,8 +122,7 @@ static pool_t *pool_tries, *pool_objects; static trie_t *trie_get(trie_t *parent, char *name, int pos) { trie_t *trie; - static int total = 0; - total ++; + if ((trie = pool_get(pool_tries))) { for (int i = 0; i < TRIESIZE; ++i) trie->child[i] = NULL; @@ -148,9 +147,8 @@ static trie_t *trie_find(trie_t *root, char *name) static object_t *object_find(trie_t *root, char *name) { trie_t *trie = trie_find(root, name); - static int total = 0; + if (!trie->object) { - total ++; trie->object = pool_get(pool_objects); trie->object->parent = NULL; strcpy(trie->object->name, name);