aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/hash.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:57:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:57:31 +0100
commit379055dbbb4af997b4d3ffb161d447872d7ca357 (patch)
tree3774553d470f93e12ddeb454aad9b3b607cf8918 /src/libutil/hash.h
parent602ae7a0b7e215ba2677131b8fdc70abc156b3ca (diff)
downloadrspamd-379055dbbb4af997b4d3ffb161d447872d7ca357.tar.gz
rspamd-379055dbbb4af997b4d3ffb161d447872d7ca357.zip
Unify style without sorting headers.
Diffstat (limited to 'src/libutil/hash.h')
-rw-r--r--src/libutil/hash.h99
1 files changed, 60 insertions, 39 deletions
diff --git a/src/libutil/hash.h b/src/libutil/hash.h
index c5d4639af..7f4f82b43 100644
--- a/src/libutil/hash.h
+++ b/src/libutil/hash.h
@@ -10,49 +10,50 @@
#include "mem_pool.h"
struct rspamd_hash_node {
- gpointer key;
- gpointer value;
- guint key_hash;
+ gpointer key;
+ gpointer value;
+ guint key_hash;
struct rspamd_hash_node *next;
};
typedef struct rspamd_hash_s {
- gint size;
- gint nnodes;
+ gint size;
+ gint nnodes;
struct rspamd_hash_node **nodes;
- GHashFunc hash_func;
- GEqualFunc key_equal_func;
- gint shared;
- rspamd_mempool_rwlock_t *lock;
- rspamd_mempool_t *pool;
+ GHashFunc hash_func;
+ GEqualFunc key_equal_func;
+ gint shared;
+ rspamd_mempool_rwlock_t *lock;
+ rspamd_mempool_t *pool;
} rspamd_hash_t;
-typedef void (*lru_cache_insert_func)(gpointer storage, gpointer key, gpointer value);
+typedef void (*lru_cache_insert_func)(gpointer storage, gpointer key,
+ gpointer value);
typedef gpointer (*lru_cache_lookup_func)(gpointer storage, gpointer key);
typedef gboolean (*lru_cache_delete_func)(gpointer storage, gpointer key);
typedef void (*lru_cache_destroy_func)(gpointer storage);
typedef struct rspamd_lru_hash_s {
- gint maxsize;
- gint maxage;
- GDestroyNotify value_destroy;
- GDestroyNotify key_destroy;
- GQueue *q;
- gpointer storage;
- lru_cache_insert_func insert_func;
- lru_cache_lookup_func lookup_func;
- lru_cache_delete_func delete_func;
- lru_cache_destroy_func destroy_func;
+ gint maxsize;
+ gint maxage;
+ GDestroyNotify value_destroy;
+ GDestroyNotify key_destroy;
+ GQueue *q;
+ gpointer storage;
+ lru_cache_insert_func insert_func;
+ lru_cache_lookup_func lookup_func;
+ lru_cache_delete_func delete_func;
+ lru_cache_destroy_func destroy_func;
} rspamd_lru_hash_t;
typedef struct rspamd_lru_element_s {
- gpointer data;
- gpointer key;
- time_t store_time;
- guint ttl;
- rspamd_lru_hash_t *hash;
- GList *link;
+ gpointer data;
+ gpointer key;
+ time_t store_time;
+ guint ttl;
+ rspamd_lru_hash_t *hash;
+ GList *link;
} rspamd_lru_element_t;
@@ -65,7 +66,9 @@ typedef struct rspamd_lru_element_s {
* @param key_equal_func pointer to function for comparing keys
* @return new rspamd_hash object
*/
-rspamd_hash_t* rspamd_hash_new (rspamd_mempool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func);
+rspamd_hash_t * rspamd_hash_new (rspamd_mempool_t *pool,
+ GHashFunc hash_func,
+ GEqualFunc key_equal_func);
/**
* Create new hash in specified pool using shared memory
@@ -74,7 +77,10 @@ rspamd_hash_t* rspamd_hash_new (rspamd_mempool_t *pool, GHashFunc hash_func, GEq
* @param key_equal_func pointer to function for comparing keys
* @return new rspamd_hash object
*/
-rspamd_hash_t* rspamd_hash_new_shared (rspamd_mempool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func, gint size);
+rspamd_hash_t * rspamd_hash_new_shared (rspamd_mempool_t *pool,
+ GHashFunc hash_func,
+ GEqualFunc key_equal_func,
+ gint size);
/**
* Insert item in hash
@@ -99,7 +105,7 @@ gboolean rspamd_hash_remove (rspamd_hash_t *hash, gpointer key);
*/
gpointer rspamd_hash_lookup (rspamd_hash_t *hash, gpointer key);
-/**
+/**
* Iterate throught hash
* @param hash hash object
* @param func user's function that would be called for each key/value pair
@@ -115,8 +121,12 @@ void rspamd_hash_foreach (rspamd_hash_t *hash, GHFunc func, gpointer user_data);
* @param key_equal_func pointer to function for comparing keys
* @return new rspamd_hash object
*/
-rspamd_lru_hash_t* rspamd_lru_hash_new (GHashFunc hash_func, GEqualFunc key_equal_func,
- gint maxsize, gint maxage, GDestroyNotify key_destroy, GDestroyNotify value_destroy);
+rspamd_lru_hash_t * rspamd_lru_hash_new (GHashFunc hash_func,
+ GEqualFunc key_equal_func,
+ gint maxsize,
+ gint maxage,
+ GDestroyNotify key_destroy,
+ GDestroyNotify value_destroy);
/**
* Create new lru hash with custom storage
@@ -126,25 +136,36 @@ rspamd_lru_hash_t* rspamd_lru_hash_new (GHashFunc hash_func, GEqualFunc key_equa
* @param key_equal_func pointer to function for comparing keys
* @return new rspamd_hash object
*/
-rspamd_lru_hash_t* rspamd_lru_hash_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
- gint maxsize, gint maxage, GDestroyNotify key_destroy, GDestroyNotify value_destroy,
- gpointer storage, lru_cache_insert_func insert_func, lru_cache_lookup_func lookup_func,
- lru_cache_delete_func delete_func);
+rspamd_lru_hash_t * rspamd_lru_hash_new_full (GHashFunc hash_func,
+ GEqualFunc key_equal_func,
+ gint maxsize,
+ gint maxage,
+ GDestroyNotify key_destroy,
+ GDestroyNotify value_destroy,
+ gpointer storage,
+ lru_cache_insert_func insert_func,
+ lru_cache_lookup_func lookup_func,
+ lru_cache_delete_func delete_func);
/**
* Lookup item from hash
* @param hash hash object
* @param key key to find
* @return value of key or NULL if key is not found
*/
-gpointer rspamd_lru_hash_lookup (rspamd_lru_hash_t *hash, gpointer key, time_t now);
+gpointer rspamd_lru_hash_lookup (rspamd_lru_hash_t *hash,
+ gpointer key,
+ time_t now);
/**
* Insert item in hash
* @param hash hash object
* @param key key to insert
* @param value value of key
*/
-void rspamd_lru_hash_insert (rspamd_lru_hash_t *hash, gpointer key, gpointer value,
- time_t now, guint ttl);
+void rspamd_lru_hash_insert (rspamd_lru_hash_t *hash,
+ gpointer key,
+ gpointer value,
+ time_t now,
+ guint ttl);
/**
* Remove lru hash