From 63594b25d22a5fa4193cc9c58143aa34531d8912 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sat, 18 Jul 2020 15:06:04 -0400 Subject: Fix move map free functions within src for function declarations. map_free_aux() was called in remove (not added yet), and needed the function declaration earlier moving free functions next to structure declaration seemed the best organization for this. --- collections/map/map.c | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/collections/map/map.c b/collections/map/map.c index 8bfd885..701e217 100644 --- a/collections/map/map.c +++ b/collections/map/map.c @@ -17,6 +17,36 @@ struct map_node { struct map_node *left, *right, *parent; }; +void map_free_aux(root) +struct map_node *root; +{ + if (!root) + return; + + map_free_aux(root->left); + root->left = NULL; + + map_free_aux(root->right); + root->right= NULL; + + root->parent = NULL; + + free(root); + return; +} + +void map_free(root) +map *root; +{ + if (!root) + return; + + map_free_aux(root->root); + + free(root); + return; +} + int map_height(root) struct map_node *root; { @@ -398,33 +428,3 @@ map *root; map_clear_aux(root->root); root->root = NULL; } - -void map_free_aux(root) -struct map_node *root; -{ - if (!root) - return; - - map_free_aux(root->left); - root->left = NULL; - - map_free_aux(root->right); - root->right= NULL; - - root->parent = NULL; - - free(root); - return; -} - -void map_free(root) -map *root; -{ - if (!root) - return; - - map_free_aux(root->root); - - free(root); - return; -} -- cgit v1.1