summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-09-23 03:25:22 +0000
committerDavid Robillard <d@drobilla.net>2014-09-23 03:25:22 +0000
commit28f948ed40c8340e906e8ba719ed91aa2bca4538 (patch)
tree60fab81cbe45c59eaa56091906537c38167b2546
parentc5971b8a7b960803440d894b68b4620e6996ae13 (diff)
downloadzix-28f948ed40c8340e906e8ba719ed91aa2bca4538.tar.gz
zix-28f948ed40c8340e906e8ba719ed91aa2bca4538.tar.bz2
zix-28f948ed40c8340e906e8ba719ed91aa2bca4538.zip
Allow non-const visitation of hash nodes.
Update doc comments. git-svn-id: http://svn.drobilla.net/zix/trunk@88 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
-rw-r--r--test/hash_test.c2
-rw-r--r--zix/hash.c8
-rw-r--r--zix/hash.h26
3 files changed, 18 insertions, 18 deletions
diff --git a/test/hash_test.c b/test/hash_test.c
index aeafc06..7da514b 100644
--- a/test/hash_test.c
+++ b/test/hash_test.c
@@ -56,7 +56,7 @@ test_fail(const char* fmt, ...)
static unsigned n_checked = 0;
static void
-check(const void* value, void* user_data)
+check(void* value, void* user_data)
{
if (strlen(*(const char*const*)value) >= 3) {
++n_checked;
diff --git a/zix/hash.c b/zix/hash.c
index 9e0ee0f..f633e16 100644
--- a/zix/hash.c
+++ b/zix/hash.c
@@ -46,8 +46,8 @@ struct ZixHashImpl {
unsigned count;
};
-static inline const void*
-zix_hash_value(const ZixHashEntry* entry)
+static inline void*
+zix_hash_value(ZixHashEntry* entry)
{
return entry + 1;
}
@@ -219,13 +219,13 @@ zix_hash_remove(ZixHash* hash, const void* value)
}
ZIX_API void
-zix_hash_foreach(const ZixHash* hash,
+zix_hash_foreach(ZixHash* hash,
ZixHashVisitFunc f,
void* user_data)
{
for (unsigned b = 0; b < *hash->n_buckets; ++b) {
ZixHashEntry* bucket = hash->buckets[b];
- for (const ZixHashEntry* e = bucket; e; e = e->next) {
+ for (ZixHashEntry* e = bucket; e; e = e->next) {
f(zix_hash_value(e), user_data);
}
}
diff --git a/zix/hash.h b/zix/hash.h
index c992117..e6f4028 100644
--- a/zix/hash.h
+++ b/zix/hash.h
@@ -43,8 +43,8 @@ typedef uint32_t (*ZixHashFunc)(const void* value);
/**
Function to visit a hash element.
*/
-typedef void (*ZixHashVisitFunc)(const void* value,
- void* user_data);
+typedef void (*ZixHashVisitFunc)(void* value,
+ void* user_data);
/**
Create a new hash table.
@@ -65,29 +65,29 @@ zix_hash_new(ZixHashFunc hash_func,
size_t value_size);
/**
- Free @p hash.
+ Free `hash`.
*/
ZIX_API void
zix_hash_free(ZixHash* hash);
/**
- Return the number of elements in @p hash.
+ Return the number of elements in `hash`.
*/
ZIX_API size_t
zix_hash_size(const ZixHash* hash);
/**
- Insert an item into @p hash.
+ Insert an item into `hash`.
If no matching value is found, ZIX_STATUS_SUCCESS will be returned, and @p
- inserted will be pointed to the copy of @p value made in the new hash node.
+ inserted will be pointed to the copy of `value` made in the new hash node.
If a matching value already exists, ZIX_STATUS_EXISTS will be returned, and
- @p inserted will be pointed to the existing value.
+ `inserted` will be pointed to the existing value.
@param hash The hash table.
@param value The value to be inserted.
- @param inserted The copy of @p value in the hash table.
+ @param inserted The copy of `value` in the hash table.
@return ZIX_STATUS_SUCCESS, ZIX_STATUS_EXISTS, or ZIX_STATUS_NO_MEM.
*/
ZIX_API ZixStatus
@@ -96,7 +96,7 @@ zix_hash_insert(ZixHash* hash,
const void** inserted);
/**
- Remove an item from @p hash.
+ Remove an item from `hash`.
@param hash The hash table.
@param value The value to remove.
@@ -107,7 +107,7 @@ zix_hash_remove(ZixHash* hash,
const void* value);
/**
- Search for an item in @p hash.
+ Search for an item in `hash`.
@param hash The hash table.
@param value The value to search for.
@@ -117,14 +117,14 @@ zix_hash_find(const ZixHash* hash,
const void* value);
/**
- Call @p f on each value in @p hash.
+ Call `f` on each value in `hash`.
@param hash The hash table.
@param f The function to call on each value.
- @param user_data The user_data parameter passed to @p f.
+ @param user_data The user_data parameter passed to `f`.
*/
ZIX_API void
-zix_hash_foreach(const ZixHash* hash,
+zix_hash_foreach(ZixHash* hash,
ZixHashVisitFunc f,
void* user_data);