From 1faec2ebd0c7151ff67390f7de7873f4b07cabb9 Mon Sep 17 00:00:00 2001 From: Soikk Date: Sat, 13 Aug 2022 21:32:42 +0200 Subject: Updated README and fixed error on example images. Removed deleted dependencies. Fixed AVL tree bug. --- src/storage.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/storage.c') diff --git a/src/storage.c b/src/storage.c index bc5ab6b..dc1ad88 100644 --- a/src/storage.c +++ b/src/storage.c @@ -504,13 +504,17 @@ int storeAVLTree(tree root, FILE *fp){ return 0; } -static node *arrayToNodes(uint64_t *array, uint64_t i, uint64_t maxNodes){ - if(i >= maxNodes*2){ +static node *arrayToNodes(uint64_t *array, uint64_t pos, uint64_t maxNodes){ + if(pos >= maxNodes*2){ return NULL; } - node *n = newNode(array[i+0], array[i+1]); - n->left = arrayToNodes(array, (2*i + 1)*2, maxNodes); - n->right = arrayToNodes(array, (2*i + 2)*2, maxNodes); + uint64_t h = array[pos+0], i = array[pos+1]; + if(h == UINTMAX_MAX && i == UINTMAX_MAX){ + return NULL; + } + node *n = newNode(h, i); + n->left = arrayToNodes(array, (2*pos + 1)*2, maxNodes); + n->right = arrayToNodes(array, (2*pos + 2)*2, maxNodes); return n; } -- cgit v1.2.3