From f4eb0173332488359c982003aafd5d31e31fe2b2 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Mon, 20 Nov 2006 17:13:21 +0000 Subject: [PATCH] ngx_rbtree_insert_value() --- src/core/ngx_rbtree.c | 33 +++++++++++++++++++++++++++++++++ src/core/ngx_rbtree.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/src/core/ngx_rbtree.c b/src/core/ngx_rbtree.c index ae973e5b0..a9d630520 100644 --- a/src/core/ngx_rbtree.c +++ b/src/core/ngx_rbtree.c @@ -99,6 +99,39 @@ ngx_rbtree_insert(ngx_thread_volatile ngx_rbtree_t *tree, } +void +ngx_rbtree_insert_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, + ngx_rbtree_node_t *sentinel) +{ + for ( ;; ) { + + if (node->key < temp->key) { + + if (temp->left == sentinel) { + temp->left = node; + break; + } + + temp = temp->left; + + } else { + + if (temp->right == sentinel) { + temp->right = node; + break; + } + + temp = temp->right; + } + } + + node->parent = temp; + node->left = sentinel; + node->right = sentinel; + ngx_rbt_red(node); +} + + void ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) diff --git a/src/core/ngx_rbtree.h b/src/core/ngx_rbtree.h index c03703dc2..008db2a25 100644 --- a/src/core/ngx_rbtree.h +++ b/src/core/ngx_rbtree.h @@ -44,6 +44,8 @@ void ngx_rbtree_insert(ngx_thread_volatile ngx_rbtree_t *tree, ngx_rbtree_node_t *node); void ngx_rbtree_delete(ngx_thread_volatile ngx_rbtree_t *tree, ngx_rbtree_node_t *node); +void ngx_rbtree_insert_value(ngx_rbtree_node_t *root, ngx_rbtree_node_t *node, + ngx_rbtree_node_t *sentinel); void ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *root, ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel);