aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-29 09:03:55 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-29 09:03:55 -0800
commit76c1836aaf2e7738829834c043ba1bc4d6ed6cec (patch)
treee8d178106ce939fe71e4d0e26ab772e21ae21a7b /src/core
parentba8cbe2bd52199ff64270901f2981894a9b553d2 (diff)
downloadnng-76c1836aaf2e7738829834c043ba1bc4d6ed6cec.tar.gz
nng-76c1836aaf2e7738829834c043ba1bc4d6ed6cec.tar.bz2
nng-76c1836aaf2e7738829834c043ba1bc4d6ed6cec.zip
Test suite for idhash, fix symbol errors, and value changing.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/idhash.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/idhash.c b/src/core/idhash.c
index 85759b93..050ba4fb 100644
--- a/src/core/idhash.c
+++ b/src/core/idhash.c
@@ -113,7 +113,7 @@ nni_hash_resize(nni_idhash *h)
int
-nni_hash_remove(nni_idhash *h, uint32_t id)
+nni_idhash_remove(nni_idhash *h, uint32_t id)
{
uint32_t index = id & (h->ih_cap - 1);
@@ -138,7 +138,7 @@ nni_hash_remove(nni_idhash *h, uint32_t id)
int
-nni_hash_insert(nni_idhash *h, uint32_t id, void *val)
+nni_idhash_insert(nni_idhash *h, uint32_t id, void *val)
{
uint32_t index;
@@ -149,10 +149,13 @@ nni_hash_insert(nni_idhash *h, uint32_t id, void *val)
}
index = id & (h->ih_cap - 1);
for (;;) {
- if (h->ih_entries[index].ihe_val == NULL) {
+ if ((h->ih_entries[index].ihe_val == NULL) ||
+ (h->ih_entries[index].ihe_key == id)) {
+ if (h->ih_entries[index].ihe_val == NULL) {
+ h->ih_count++;
+ }
h->ih_entries[index].ihe_key = id;
h->ih_entries[index].ihe_val = val;
- h->ih_count++;
return (0);
}
index = NNI_IDHASH_NEXTPROBE(h, index);