version 1.1.1.2, 2012/05/29 12:26:49
|
version 1.1.1.3, 2013/07/22 10:46:12
|
Line 1
|
Line 1
|
/* |
/* |
* Copyright (c) 2004-2005, 2007, 2009-2011 | * Copyright (c) 2004-2005, 2007, 2009-2013 |
* Todd C. Miller <Todd.Miller@courtesan.com> |
* Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 43
|
Line 43
|
#include <config.h> |
#include <config.h> |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> |
|
|
|
#include <stdio.h> |
#include <stdio.h> |
#ifdef STDC_HEADERS |
#ifdef STDC_HEADERS |
Line 413 rbrepair(struct rbtree *tree, struct rbnode *node)
|
Line 412 rbrepair(struct rbtree *tree, struct rbnode *node)
|
struct rbnode *sibling; |
struct rbnode *sibling; |
debug_decl(rbrepair, SUDO_DEBUG_RBTREE) |
debug_decl(rbrepair, SUDO_DEBUG_RBTREE) |
|
|
while (node->color == black && node != rbroot(tree)) { | while (node->color == black && node != rbfirst(tree)) { |
if (node == node->parent->left) { |
if (node == node->parent->left) { |
sibling = node->parent->right; |
sibling = node->parent->right; |
if (sibling->color == red) { |
if (sibling->color == red) { |
Line 436 rbrepair(struct rbtree *tree, struct rbnode *node)
|
Line 435 rbrepair(struct rbtree *tree, struct rbnode *node)
|
node->parent->color = black; |
node->parent->color = black; |
sibling->right->color = black; |
sibling->right->color = black; |
rotate_left(tree, node->parent); |
rotate_left(tree, node->parent); |
node = rbroot(tree); /* exit loop */ | node = rbfirst(tree); /* exit loop */ |
} |
} |
} else { /* if (node == node->parent->right) */ |
} else { /* if (node == node->parent->right) */ |
sibling = node->parent->left; |
sibling = node->parent->left; |
Line 460 rbrepair(struct rbtree *tree, struct rbnode *node)
|
Line 459 rbrepair(struct rbtree *tree, struct rbnode *node)
|
node->parent->color = black; |
node->parent->color = black; |
sibling->left->color = black; |
sibling->left->color = black; |
rotate_right(tree, node->parent); |
rotate_right(tree, node->parent); |
node = rbroot(tree); /* exit loop */ | node = rbfirst(tree); /* exit loop */ |
} |
} |
} |
} |
} |
} |