aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/trie.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/trie.c
parente0483657ff6cf1adc828ccce457814d61fe90a0d (diff)
downloadrspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.tar.gz
rspamd-fe79d8c5a39f2b717f78cc3f3ef21b3cfc46500b.zip
Revert "Unify code style."
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
Diffstat (limited to 'src/libutil/trie.c')
-rw-r--r--src/libutil/trie.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/libutil/trie.c b/src/libutil/trie.c
index 8c9e0f600..394c4e939 100644
--- a/src/libutil/trie.c
+++ b/src/libutil/trie.c
@@ -25,10 +25,10 @@
#include "mem_pool.h"
#include "trie.h"
-rspamd_trie_t *
+rspamd_trie_t*
rspamd_trie_create (gboolean icase)
{
- rspamd_trie_t *new;
+ rspamd_trie_t *new;
new = g_malloc (sizeof (rspamd_trie_t));
@@ -48,25 +48,20 @@ rspamd_trie_create (gboolean icase)
* Insert a single character as the specified level of the suffix tree
*/
static struct rspamd_trie_state *
-rspamd_trie_insert_char (rspamd_trie_t *trie,
- guint depth,
- struct rspamd_trie_state *pos,
- gchar c)
+rspamd_trie_insert_char (rspamd_trie_t *trie, guint depth, struct rspamd_trie_state *pos, gchar c)
{
- struct rspamd_trie_match *new_match;
- struct rspamd_trie_state *new_pos;
+ struct rspamd_trie_match *new_match;
+ struct rspamd_trie_state *new_pos;
/* New match is inserted before pos */
- new_match =
- rspamd_mempool_alloc (trie->pool, sizeof (struct rspamd_trie_match));
+ new_match = rspamd_mempool_alloc (trie->pool, sizeof (struct rspamd_trie_match));
new_match->next = pos->match;
new_match->c = c;
/* Now set match link */
pos->match = new_match;
- new_match->state =
- rspamd_mempool_alloc (trie->pool, sizeof (struct rspamd_trie_state));
+ new_match->state = rspamd_mempool_alloc (trie->pool, sizeof (struct rspamd_trie_state));
new_pos = new_match->state;
new_pos->match = NULL;
new_pos->fail = &trie->root;
@@ -91,7 +86,7 @@ rspamd_trie_insert_char (rspamd_trie_t *trie,
static inline struct rspamd_trie_match *
check_match (struct rspamd_trie_state *s, gchar c)
{
- struct rspamd_trie_match *match = s->match;
+ struct rspamd_trie_match *match = s->match;
while (match && match->c != c) {
match = match->next;
@@ -103,11 +98,11 @@ check_match (struct rspamd_trie_state *s, gchar c)
void
rspamd_trie_insert (rspamd_trie_t *trie, const gchar *pattern, gint pattern_id)
{
- const guchar *p = pattern;
- struct rspamd_trie_state *q, *q1, *r, *cur_node;
- struct rspamd_trie_match *m, *n;
- guint i, depth = 0;
- gchar c;
+ const guchar *p = pattern;
+ struct rspamd_trie_state *q, *q1, *r, *cur_node;
+ struct rspamd_trie_match *m, *n;
+ guint i, depth = 0;
+ gchar c;
/* Insert pattern to the trie */
@@ -123,8 +118,8 @@ rspamd_trie_insert (rspamd_trie_t *trie, const gchar *pattern, gint pattern_id)
else {
cur_node = m->state;
}
- p++;
- depth++;
+ p ++;
+ depth ++;
}
cur_node->final = depth;
@@ -170,16 +165,13 @@ rspamd_trie_insert (rspamd_trie_t *trie, const gchar *pattern, gint pattern_id)
}
}
-const gchar *
-rspamd_trie_lookup (rspamd_trie_t *trie,
- const gchar *buffer,
- gsize buflen,
- gint *matched_id)
+const gchar*
+rspamd_trie_lookup (rspamd_trie_t *trie, const gchar *buffer, gsize buflen, gint *matched_id)
{
- const guchar *p = buffer, *prev, *ret;
- struct rspamd_trie_state *cur_node;
- struct rspamd_trie_match *m = NULL;
- gchar c;
+ const guchar *p = buffer, *prev, *ret;
+ struct rspamd_trie_state *cur_node;
+ struct rspamd_trie_match *m = NULL;
+ gchar c;
cur_node = &trie->root;
@@ -203,9 +195,9 @@ rspamd_trie_lookup (rspamd_trie_t *trie,
/* We have tried the pattern but eventually it was not found */
cur_node = &trie->root;
ret = p;
- p++;
+ p ++;
prev = p;
- buflen--;
+ buflen --;
continue;
}
@@ -221,9 +213,9 @@ rspamd_trie_lookup (rspamd_trie_t *trie,
return (const gchar *) ret;
}
}
- p++;
+ p ++;
prev = p;
- buflen--;
+ buflen --;
}
return NULL;