aboutsummaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2015-12-30 15:10:05 -0500
committerFranklin Wei <git@fwei.tk>2015-12-30 15:10:05 -0500
commit954fffd4845642e2fa3af0ee75e845ef68497766 (patch)
tree234219215e2fc86d62cdafa50daaea24ec439f69 /src/hash.h
parent22f5eaa809a8daac6ce8bf421b89290f7258b42e (diff)
downloadnetcosm-954fffd4845642e2fa3af0ee75e845ef68497766.zip
netcosm-954fffd4845642e2fa3af0ee75e845ef68497766.tar.gz
netcosm-954fffd4845642e2fa3af0ee75e845ef68497766.tar.bz2
netcosm-954fffd4845642e2fa3af0ee75e845ef68497766.tar.xz
docs and stuff
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/hash.h b/src/hash.h
index 3abba9a..28a5352 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -30,10 +30,18 @@ void *hash_init(size_t tabsz, unsigned (*hash_fn)(const void*),
void hash_setfreedata_cb(void*, void (*cb)(void *data));
void hash_setfreekey_cb(void*, void (*cb)(void *key));
+/*
+ * free all data associated with a map handle
+ *
+ * if callbacks for free'ing keys or data are installed, they will be
+ * called.
+ */
void hash_free(void*);
-/* insert a pair, returns null if not already found, otherwise
- return the existing data pointer */
+/*
+ * insert a pair, returns null if not already found, otherwise returns
+ * the existing data pointer
+ */
void *hash_insert(void*, const void *key, const void *data);
/* returns NULL if not found */
@@ -41,8 +49,15 @@ void *hash_lookup(void*, const void *key);
bool hash_remove(void *ptr, const void *key);
-/* use like you would strtok_r */
-/* allocates a buffer that's freed once all elements are processed */
+/*
+ * use like you would strtok_r
+ *
+ * allocates a buffer that's freed once all elements are processed if
+ * you must stop iteration without processing every element,
+ * free(*saved)
+ *
+ * if keyptr!=NULL, the key pointer will be saved to *keyptr
+ */
void *hash_iterate(void *map, void **saved, void **keyptr);
struct hash_pair {