aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/radix.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:53:08 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:53:08 +0100
commitfe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b (patch)
treec84e6a5d4c5cd78a7a2cc3c7adbc7af5d0541682 /src/libutil/radix.c
parente0483657ff6cf1adc828ccce457814d61fe90a0d (diff)
downloadrspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.tar.gz
rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.zip
Revert "Unify code style."
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
Diffstat (limited to 'src/libutil/radix.c')
-rw-r--r--src/libutil/radix.c92
1 files changed, 36 insertions, 56 deletions
diff --git a/src/libutil/radix.c b/src/libutil/radix.c
index c33ac0d05..7af665331 100644
--- a/src/libutil/radix.c
+++ b/src/libutil/radix.c
@@ -24,15 +24,15 @@
#include "config.h"
-#include "mem_pool.h"
#include "radix.h"
+#include "mem_pool.h"
-static void * radix_alloc (radix_tree_t * tree);
+static void *radix_alloc (radix_tree_t * tree);
-radix_tree_t *
+radix_tree_t *
radix_tree_create (void)
{
- radix_tree_t *tree;
+ radix_tree_t *tree;
tree = g_malloc (sizeof (radix_tree_t));
if (tree == NULL) {
@@ -62,14 +62,10 @@ enum radix_insert_type {
};
static uintptr_t
-radix32tree_insert_common (radix_tree_t * tree,
- guint32 key,
- guint32 mask,
- uintptr_t value,
- enum radix_insert_type type)
+radix32tree_insert_common (radix_tree_t * tree, guint32 key, guint32 mask, uintptr_t value, enum radix_insert_type type)
{
- guint32 bit;
- radix_node_t *node, *next;
+ guint32 bit;
+ radix_node_t *node, *next;
bit = 0x80000000;
@@ -96,14 +92,14 @@ radix32tree_insert_common (radix_tree_t * tree,
if (node->value != RADIX_NO_VALUE) {
/* Value was found, switch on insert type */
switch (type) {
- case RADIX_INSERT:
- return 1;
- case RADIX_ADD:
- node->value += value;
- return value;
- case RADIX_REPLACE:
- node->value = value;
- return 1;
+ case RADIX_INSERT:
+ return 1;
+ case RADIX_ADD:
+ node->value += value;
+ return value;
+ case RADIX_REPLACE:
+ node->value = value;
+ return 1;
}
}
@@ -141,33 +137,22 @@ radix32tree_insert_common (radix_tree_t * tree,
return 0;
}
-gint
-radix32tree_insert (radix_tree_t *tree,
- guint32 key,
- guint32 mask,
- uintptr_t value)
+gint
+radix32tree_insert (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value)
{
- return (gint)radix32tree_insert_common (tree, key, mask, value,
- RADIX_INSERT);
+ return (gint)radix32tree_insert_common (tree, key, mask, value, RADIX_INSERT);
}
-uintptr_t
+uintptr_t
radix32tree_add (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value)
{
return radix32tree_insert_common (tree, key, mask, value, RADIX_ADD);
}
-gint
-radix32tree_replace (radix_tree_t *tree,
- guint32 key,
- guint32 mask,
- uintptr_t value)
+gint
+radix32tree_replace (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value)
{
- return (gint)radix32tree_insert_common (tree,
- key,
- mask,
- value,
- RADIX_REPLACE);
+ return (gint)radix32tree_insert_common (tree, key, mask, value, RADIX_REPLACE);
}
/*
@@ -177,17 +162,14 @@ radix32tree_replace (radix_tree_t *tree,
* 5 words total in stack
*/
static gboolean
-radix_recurse_nodes (radix_node_t *node,
- radix_tree_traverse_func func,
- void *user_data,
- gint level)
+radix_recurse_nodes (radix_node_t *node, radix_tree_traverse_func func, void *user_data, gint level)
{
if (node->left) {
if (radix_recurse_nodes (node->left, func, user_data, level + 1)) {
return TRUE;
}
}
-
+
if (node->value != RADIX_NO_VALUE) {
if (func (node->key, level, node->value, user_data)) {
return TRUE;
@@ -204,19 +186,17 @@ radix_recurse_nodes (radix_node_t *node,
}
void
-radix32tree_traverse (radix_tree_t *tree,
- radix_tree_traverse_func func,
- void *user_data)
+radix32tree_traverse (radix_tree_t *tree, radix_tree_traverse_func func, void *user_data)
{
- radix_recurse_nodes (tree->root, func, user_data, 0);
+ radix_recurse_nodes (tree->root, func, user_data, 0);
}
gint
radix32tree_delete (radix_tree_t * tree, guint32 key, guint32 mask)
{
- guint32 bit;
- radix_node_t *node;
+ guint32 bit;
+ radix_node_t *node;
bit = 0x80000000;
node = tree->root;
@@ -246,7 +226,7 @@ radix32tree_delete (radix_tree_t * tree, guint32 key, guint32 mask)
return -1;
}
- for (;; ) {
+ for (;;) {
if (node->parent->right == node) {
node->parent->right = NULL;
@@ -277,9 +257,9 @@ radix32tree_delete (radix_tree_t * tree, guint32 key, guint32 mask)
uintptr_t
radix32tree_find (radix_tree_t * tree, guint32 key)
{
- guint32 bit;
- uintptr_t value;
- radix_node_t *node;
+ guint32 bit;
+ uintptr_t value;
+ radix_node_t *node;
bit = 0x80000000;
value = RADIX_NO_VALUE;
@@ -305,10 +285,10 @@ radix32tree_find (radix_tree_t * tree, guint32 key)
}
-static void *
+static void *
radix_alloc (radix_tree_t * tree)
{
- gchar *p;
+ gchar *p;
p = rspamd_mempool_alloc (tree->pool, sizeof (radix_node_t));
@@ -336,6 +316,6 @@ radix32_tree_find_addr (radix_tree_t *tree, rspamd_inet_addr_t *addr)
return radix32tree_find (tree, ntohl (addr->addr.s4.sin_addr.s_addr));
}
-/*
- * vi:ts=4
+/*
+ * vi:ts=4
*/