aboutsummaryrefslogtreecommitdiffstats
path: root/src/radix.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-03 13:59:12 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-03 13:59:12 +0400
commitc9d98a8fc24f76d979ad479eff2fa66b31703832 (patch)
tree3e7da89081fd35425db582dacbdd3277adf40aaf /src/radix.c
parent563a106f3a57e460b9c5ea06a2eb4e6456f9e080 (diff)
downloadrspamd-c9d98a8fc24f76d979ad479eff2fa66b31703832.tar.gz
rspamd-c9d98a8fc24f76d979ad479eff2fa66b31703832.zip
* Various bugfixes in map and radix code
Diffstat (limited to 'src/radix.c')
-rw-r--r--src/radix.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/src/radix.c b/src/radix.c
index 8b9df48a7..e55e9e5ba 100644
--- a/src/radix.c
+++ b/src/radix.c
@@ -30,15 +30,16 @@
static void *radix_alloc (radix_tree_t *tree);
radix_tree_t *
-radix_tree_create (memory_pool_t *pool)
+radix_tree_create ()
{
radix_tree_t *tree;
- tree = memory_pool_alloc (pool, sizeof(radix_tree_t));
+ tree = g_malloc (sizeof(radix_tree_t));
if (tree == NULL) {
return NULL;
}
-
+
+ tree->pool = memory_pool_new (memory_pool_get_size ());
tree->size = 0;
tree->root = radix_alloc (tree);
@@ -50,7 +51,6 @@ radix_tree_create (memory_pool_t *pool)
tree->root->left = NULL;
tree->root->parent = NULL;
tree->root->value = RADIX_NO_VALUE;
- tree->pool = pool;
return tree;
}
@@ -228,37 +228,10 @@ radix_alloc (radix_tree_t *tree)
void
radix_tree_free (radix_tree_t *tree)
{
- radix_node_t *node, *tmp;
-
- node = tree->root;
-
- for (;;) {
- /* We are at the trie root and we have no more leaves, end of algorithm */
- if (!node->left && !node->right && !node->parent) {
- break;
- }
-
- /* Traverse to the end of trie */
- while (node->left || node->right) {
- if (node->left) {
- node = node->left;
- }
- else {
- node = node->right;
- }
- }
- /* Found leaf node, free it */
- if (node->parent->right == node) {
- node->parent->right = NULL;
-
- } else {
- node->parent->left = NULL;
- }
-
- tmp = node;
- /* Go up */
- node = node->parent;
- }
+
+ g_return_if_fail (tree != NULL);
+ memory_pool_delete (tree->pool);
+ g_free (tree);
}
/*