diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-10-05 17:59:23 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-10-05 17:59:23 -0700 |
| commit | eef8f5f4a4d8d05470503e7f6dc7270c7e488cb5 (patch) | |
| tree | 0a4a8c3ee44e643ce47ae55cf8fb81e06d59d5d6 /src | |
| parent | f1cb2402734567b84e2b55129f98f9764167e13e (diff) | |
| download | nng-eef8f5f4a4d8d05470503e7f6dc7270c7e488cb5.tar.gz nng-eef8f5f4a4d8d05470503e7f6dc7270c7e488cb5.tar.bz2 nng-eef8f5f4a4d8d05470503e7f6dc7270c7e488cb5.zip | |
idhash: introduce nni_idhash_count.
This will be used for some follow up work (UDP).
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/defs.h | 1 | ||||
| -rw-r--r-- | src/core/idhash.c | 6 | ||||
| -rw-r--r-- | src/core/idhash.h | 19 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/core/defs.h b/src/core/defs.h index 6050782b..d559b490 100644 --- a/src/core/defs.h +++ b/src/core/defs.h @@ -12,6 +12,7 @@ #define CORE_DEFS_H #include <stdint.h> +#include <stdbool.h> // C compilers may get unhappy when named arguments are not used. While // there are things like __attribute__((unused)) which are arguably diff --git a/src/core/idhash.c b/src/core/idhash.c index 306c751f..73763a07 100644 --- a/src/core/idhash.c +++ b/src/core/idhash.c @@ -389,3 +389,9 @@ nni_id_visit(nni_id_map *m, uint64_t *keyp, void **valp, uint32_t *cursor) *cursor = index; return (false); } + +uint32_t +nni_id_count(const nni_id_map *m) +{ + return (m->id_count); +} diff --git a/src/core/idhash.h b/src/core/idhash.h index 11cc7a08..b07404aa 100644 --- a/src/core/idhash.h +++ b/src/core/idhash.h @@ -46,15 +46,16 @@ struct nni_id_map { #define NNI_ID_FLAG_RANDOM 2 // start at a random value #define NNI_ID_FLAG_REGISTER 4 // map is registered for finalization -extern void nni_id_map_init(nni_id_map *, uint64_t, uint64_t, bool); -extern void nni_id_map_fini(nni_id_map *); -extern void *nni_id_get(nni_id_map *, uint64_t); -extern int nni_id_set(nni_id_map *, uint64_t, void *); -extern int nni_id_alloc(nni_id_map *, uint64_t *, void *); -extern int nni_id_alloc32(nni_id_map *, uint32_t *, void *); -extern int nni_id_remove(nni_id_map *, uint64_t); -extern void nni_id_map_sys_fini(void); -extern bool nni_id_visit(nni_id_map *, uint64_t *, void **, uint32_t *); +extern void nni_id_map_init(nni_id_map *, uint64_t, uint64_t, bool); +extern void nni_id_map_fini(nni_id_map *); +extern void *nni_id_get(nni_id_map *, uint64_t); +extern int nni_id_set(nni_id_map *, uint64_t, void *); +extern int nni_id_alloc(nni_id_map *, uint64_t *, void *); +extern int nni_id_alloc32(nni_id_map *, uint32_t *, void *); +extern int nni_id_remove(nni_id_map *, uint64_t); +extern void nni_id_map_sys_fini(void); +extern bool nni_id_visit(nni_id_map *, uint64_t *, void **, uint32_t *); +extern uint32_t nni_id_count(const nni_id_map *); #define NNI_ID_MAP_INITIALIZER(min, max, flags) \ { \ |
