aboutsummaryrefslogtreecommitdiff
path: root/src/core/idhash.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-29 16:58:12 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-29 16:58:12 -0800
commit541a53b857dc6e7c3ff5e642394369cf26bf4544 (patch)
treeea2be095c4453782a6ba6c7087227e17f6084639 /src/core/idhash.h
parent76c1836aaf2e7738829834c043ba1bc4d6ed6cec (diff)
downloadnng-541a53b857dc6e7c3ff5e642394369cf26bf4544.tar.gz
nng-541a53b857dc6e7c3ff5e642394369cf26bf4544.tar.bz2
nng-541a53b857dc6e7c3ff5e642394369cf26bf4544.zip
Richer tests and fixes for idhash. Also dynamically allocate idhash.
Diffstat (limited to 'src/core/idhash.h')
-rw-r--r--src/core/idhash.h19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/core/idhash.h b/src/core/idhash.h
index ffc60858..bfd0f595 100644
--- a/src/core/idhash.h
+++ b/src/core/idhash.h
@@ -23,20 +23,7 @@
// must be non-NULL. The caller is responsible for providing any
// locking required.
-// In order to make life easy, we just define the ID hash structure
-// directly, and let consumers directly inline it.
-typedef struct {
- uint32_t ihe_key;
- void * ihe_val;
-} nni_idhash_entry;
-
-typedef struct {
- uint32_t ih_cap;
- uint32_t ih_count;
- uint32_t ih_mincount;
- uint32_t ih_maxcount;
- nni_idhash_entry * ih_entries;
-} nni_idhash;
+typedef struct nni_idhash nni_idhash;
// nni_idhash_walkfn is called when walking a hash table. If the
// return value is non-zero, then nni_idhash_walk will terminate further
@@ -44,8 +31,8 @@ typedef struct {
// opaque value for the walk as its first argument, and the next two
// arguments are the hash key and the opaque value stored with it.
typedef int (*nni_idhash_walkfn)(void *, uint32_t, void *);
-extern int nni_idhash_init(nni_idhash *);
-extern void nni_idhash_fini(nni_idhash *);
+extern int nni_idhash_create(nni_idhash **);
+extern void nni_idhash_destroy(nni_idhash *);
extern int nni_idhash_find(nni_idhash *, uint32_t, void **);
extern int nni_idhash_remove(nni_idhash *, uint32_t);
extern int nni_idhash_insert(nni_idhash *, uint32_t, void *);