summaryrefslogtreecommitdiffstats
path: root/src/hash.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-05 19:48:07 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-02-05 19:48:07 +0300
commitbf6f2838403722ea571daaeec5981831313d474b (patch)
tree25fe553ce04b9f724537364c44889a7d326566b7 /src/hash.h
parent32a96e82d075bdba6e9e567080977a76830cbce2 (diff)
downloadrspamd-bf6f2838403722ea571daaeec5981831313d474b.tar.gz
rspamd-bf6f2838403722ea571daaeec5981831313d474b.zip
* Add some comments and documentation
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/hash.h b/src/hash.h
index 79931a37e..8f87bb10e 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -21,6 +21,11 @@
#include <glib.h>
#include "mem_pool.h"
+/**
+ * Hash table implementation that allows using memory pools for storage as well as using
+ * shared memory for this purpose
+ */
+
struct rspamd_hash_node {
gpointer key;
gpointer value;
@@ -42,17 +47,53 @@ typedef struct rspamd_hash_s {
#define rspamd_hash_size(x) (x)->nnodes
-/* Create new hash in specified pool */
+/**
+ * Create new hash in specified pool
+ * @param pool memory pool object
+ * @param hash_func pointer to hash function
+ * @param key_equal_func pointer to function for comparing keys
+ * @return new rspamd_hash object
+ */
rspamd_hash_t* rspamd_hash_new (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func);
-/* Create new hash in specified pool using shared memory */
+
+/**
+ * Create new hash in specified pool using shared memory
+ * @param pool memory pool object
+ * @param hash_func pointer to hash function
+ * @param key_equal_func pointer to function for comparing keys
+ * @return new rspamd_hash object
+ */
rspamd_hash_t* rspamd_hash_new_shared (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func);
-/* Insert item in hash */
+
+/**
+ * Insert item in hash
+ * @param hash hash object
+ * @param key key to insert
+ * @param value value of key
+ */
void rspamd_hash_insert (rspamd_hash_t *hash, gpointer key, gpointer value);
-/* Remove item from hash */
+
+/**
+ * Remove item from hash
+ * @param hash hash object
+ * @param key key to delete
+ */
gboolean rspamd_hash_remove (rspamd_hash_t *hash, gpointer key);
-/* Lookup item from hash */
+
+/**
+ * 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_hash_lookup (rspamd_hash_t *hash, gpointer key);
-/* Iterate throught hash */
+
+/**
+ * Iterate throught hash
+ * @param hash hash object
+ * @param func user's function that would be called for each key/value pair
+ * @param user_data pointer to user's data that would be passed to user's function
+ */
void rspamd_hash_foreach (rspamd_hash_t *hash, GHFunc func, gpointer user_data);
#endif