From 686d300046e29c467b9b674d18e703daae212092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Thu, 16 Jul 2009 18:40:33 +0000 Subject: [PATCH] Fix a bug causing tree first / last convenience pointers to be incorrect upon last node removal. --- src/redblack.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/redblack.h b/src/redblack.h index 75875c6a..127dd37f 100644 --- a/src/redblack.h +++ b/src/redblack.h @@ -300,18 +300,18 @@ do { \ typeof(e) x, y, z = e, x_parent, w; \ \ y = z; \ + if (y == (head)->first) { \ + (head)->first = RB_NEXT(y, field); \ + } \ + if (y == (head)->last) { \ + (head)->last = RB_PREV(y, field); \ + } \ if (y->field.left == NULL) { \ x = y->field.right; \ - if (y == (head)->first) { \ - (head)->first = RB_NEXT(y, field); \ - } \ } \ else { \ if (y->field.right == NULL) { \ x = y->field.left; \ - if (y == (head)->last) { \ - (head)->last = RB_PREV(y, field); \ - } \ } \ else { \ y = y->field.right; \