aboutsummaryrefslogtreecommitdiff
path: root/collections
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-07-08 23:14:31 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-07-08 23:14:31 -0400
commit9ca52d7be8835cbca3e55df6fba26c6a0dea8b19 (patch)
tree283ee45f85ab9963658c25e18e2bd663cb88cd97 /collections
parentd84bce07b9051ce140203ad9fa5af961361ffb7a (diff)
Fix check for null sub trees before setting parent during map rotation
Diffstat (limited to 'collections')
-rw-r--r--collections/map/map.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/collections/map/map.c b/collections/map/map.c
index a1c7798..c217fa2 100644
--- a/collections/map/map.c
+++ b/collections/map/map.c
@@ -50,6 +50,12 @@ struct map_node **node;
tmp->right = (*node)->left;
(*node)->left = tmp;
+ (*node)->parent = (*node)->left->parent;
+ (*node)->left->parent = *node;
+
+ if ((*node)->left->right)
+ (*node)->left->right->parent = (*node)->left;
+
return;
}
@@ -63,6 +69,12 @@ struct map_node **node;
tmp->left = (*node)->right;
(*node)->right = tmp;
+ (*node)->parent = (*node)->right->parent;
+ (*node)->right->parent = *node;
+
+ if ((*node)->right->left)
+ (*node)->right->left->parent = (*node)->right;
+
return;
}