aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-07-18 15:06:04 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-07-18 15:06:04 -0400
commit63594b25d22a5fa4193cc9c58143aa34531d8912 (patch)
treefd4b4579a53168d63ad5428451377dbb78dd5bb3
parentbcc72fab662858ace7b325ed6567d50579d1cd66 (diff)
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.
-rw-r--r--collections/map/map.c60
1 files 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;
-}