aboutsummaryrefslogtreecommitdiff
path: root/src/core/idhash.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-05 22:11:24 -0500
committerGarrett D'Amore <garrett@damore.org>2021-12-05 23:04:45 -0500
commitc9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04 (patch)
tree3a135bbee8750cc1b1869cfca6a2e6f24bf8e59c /src/core/idhash.h
parenteee06d1e8365ea1b1aa9363a3c6445745b002324 (diff)
downloadnng-c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04.tar.gz
nng-c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04.tar.bz2
nng-c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04.zip
Use static initialization for lists and mutexes.
This eliminates some run-time initialization, moving it to compile time. Additional follow up work will expand on this to simplify initialization and reduce the need for certain locks.
Diffstat (limited to 'src/core/idhash.h')
-rw-r--r--src/core/idhash.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/core/idhash.h b/src/core/idhash.h
index 0c9043ce..b2259853 100644
--- a/src/core/idhash.h
+++ b/src/core/idhash.h
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -23,28 +23,28 @@
// use table sizes that are powers of two. Note that hash items
// must be non-NULL. The table is protected by an internal lock.
-typedef struct nni_id_map nni_id_map;
-typedef struct nni_id_entry nni_id_entry;
+typedef struct nni_id_map nni_id_map;
+typedef struct nni_id_entry nni_id_entry;
// NB: These details are entirely private to the hash implementation.
// They are provided here to facilitate inlining in structures.
struct nni_id_map {
- size_t id_cap;
- size_t id_count;
- size_t id_load;
- size_t id_min_load; // considers placeholders
- size_t id_max_load;
+ uint32_t id_cap;
+ uint32_t id_count;
+ uint32_t id_load;
+ uint32_t id_min_load; // considers placeholders
+ uint32_t id_max_load;
uint32_t id_min_val;
uint32_t id_max_val;
uint32_t id_dyn_val;
nni_id_entry *id_entries;
};
-extern void nni_id_map_init(nni_id_map *, uint32_t, uint32_t, bool);
-extern void nni_id_map_fini(nni_id_map *);
+extern void nni_id_map_init(nni_id_map *, uint32_t, uint32_t, bool);
+extern void nni_id_map_fini(nni_id_map *);
extern void *nni_id_get(nni_id_map *, uint32_t);
-extern int nni_id_set(nni_id_map *, uint32_t, void *);
-extern int nni_id_alloc(nni_id_map *, uint32_t *, void *);
-extern int nni_id_remove(nni_id_map *, uint32_t);
+extern int nni_id_set(nni_id_map *, uint32_t, void *);
+extern int nni_id_alloc(nni_id_map *, uint32_t *, void *);
+extern int nni_id_remove(nni_id_map *, uint32_t);
#endif // CORE_IDHASH_H