diff options
author | filipe <filipe@19e92222-5c0b-0410-8929-a290d50e31e9> | 2007-09-13 04:12:01 +0000 |
---|---|---|
committer | filipe <filipe@19e92222-5c0b-0410-8929-a290d50e31e9> | 2007-09-13 04:12:01 +0000 |
commit | 706aef01fbbcee885fcb6d76228f669d48d16f25 (patch) | |
tree | a42509c89301d451300a3bc64dd1f2ac388bff66 /ext/http11/tst_insert.c | |
parent | 6bfa360e4a418cf6d3531334cea185be0878c0ed (diff) | |
download | unicorn-706aef01fbbcee885fcb6d76228f669d48d16f25.tar.gz |
and he also close the bug upstream :D So we are in sync with his source code and bug 10279 is closed with this commit. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@586 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'ext/http11/tst_insert.c')
-rw-r--r-- | ext/http11/tst_insert.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/ext/http11/tst_insert.c b/ext/http11/tst_insert.c index 0f83849..de50f4a 100644 --- a/ext/http11/tst_insert.c +++ b/ext/http11/tst_insert.c @@ -2,16 +2,16 @@ #include "tst.h" #include <stdio.h> #include <stdlib.h> - +#include <string.h> int tst_grow_node_free_list(struct tst *tst); int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void **exist_ptr) { struct node *current_node; struct node *new_node_tree_begin = NULL; + struct node *new_node; int key_index; int perform_loop = 1; - if (key == NULL) return TST_NULL_KEY; @@ -91,7 +91,33 @@ int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void } } } - + if(key[key_index] == 0) + { + if(tst->free_list == NULL) + { + if(tst_grow_node_free_list(tst) != 1) + return TST_ERROR; + } + new_node = tst->free_list; + tst->free_list = tst->free_list->middle; + + memcpy((void*)new_node, (void*)current_node, sizeof(struct node)); + current_node->value = 0; + if(new_node->value < 64) + { + current_node->left = new_node; + current_node->right = '\0'; + } + else + { + current_node->left = '\0'; + current_node->right = new_node; + } + + current_node->middle = data; + return TST_OK; + } + if( ((current_node->value == 0) && (key[key_index] < 64)) || ((current_node->value != 0) && (key[key_index] < current_node->value)) ) |