aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-07-08 23:14:07 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-07-08 23:14:07 -0400
commitd84bce07b9051ce140203ad9fa5af961361ffb7a (patch)
treeb7e2beba30997971ffc2d7749376c323b38d42e2
parente4a56e626030b728a7dcada8e84a77d1da3b00ae (diff)
Fix return on null tree for map balance factor
-rw-r--r--collections/map/map.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/collections/map/map.c b/collections/map/map.c
index cbb3b79..a1c7798 100644
--- a/collections/map/map.c
+++ b/collections/map/map.c
@@ -34,6 +34,9 @@ struct map_node *root;
int map_bal_factor(root)
struct map_node *root;
{
+ if (!root)
+ return 0;
+
return map_height(root->right) - map_height(root->left);
}