aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt3
-rw-r--r--src/core/idhash_test.c (renamed from src/supplemental/util/idhash_test.c)4
-rw-r--r--src/nng.c55
-rw-r--r--src/supplemental/util/CMakeLists.txt4
-rw-r--r--src/supplemental/util/idhash.c68
5 files changed, 59 insertions, 75 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index ba8b1ca8..9f5b4a95 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright 2024 Staysail Systems, Inc. <info@staystail.tech>
+# Copyright 2025 Staysail Systems, Inc. <info@staystail.tech>
#
# This software is supplied under the terms of the MIT License, a
# copy of which should be located in the distribution where this
@@ -84,6 +84,7 @@ nng_test(aio_test)
nng_test(buf_size_test)
nng_test(errors_test)
nng_test(id_test)
+nng_test(idhash_test)
nng_test(init_test)
nng_test(list_test)
nng_test(log_test)
diff --git a/src/supplemental/util/idhash_test.c b/src/core/idhash_test.c
index e0d472a0..2bf65dae 100644
--- a/src/supplemental/util/idhash_test.c
+++ b/src/core/idhash_test.c
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -9,8 +9,6 @@
#include <nuts.h>
-#include <nng/supplemental/util/idhash.h>
-
void
test_id_basic(void)
{
diff --git a/src/nng.c b/src/nng.c
index d51d781c..345f47d9 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -2179,3 +2179,58 @@ nng_udp_multicast_membership(nng_udp *udp, nng_sockaddr *sa, bool join)
return (
nni_plat_udp_multicast_membership((nni_plat_udp *) udp, sa, join));
}
+
+struct nng_id_map_s {
+ nni_id_map m;
+};
+
+int
+nng_id_map_alloc(nng_id_map **map, uint64_t lo, uint64_t hi, int flags)
+{
+ nng_id_map *m;
+
+ if ((m = NNI_ALLOC_STRUCT(m)) == NULL) {
+ return (NNG_ENOMEM);
+ }
+ nni_id_map_init(
+ &m->m, lo, hi, (flags & NNG_MAP_RANDOM) ? true : false);
+ *map = m;
+ return (0);
+}
+
+void
+nng_id_map_free(nng_id_map *map)
+{
+ nni_id_map_fini(&map->m);
+ NNI_FREE_STRUCT(map);
+}
+
+void *
+nng_id_get(nng_id_map *map, uint64_t id)
+{
+ return (nni_id_get(&map->m, id));
+}
+
+int
+nng_id_set(nng_id_map *map, uint64_t id, void *val)
+{
+ return (nni_id_set(&map->m, id, val));
+}
+
+int
+nng_id_remove(nng_id_map *map, uint64_t id)
+{
+ return (nni_id_remove(&map->m, id));
+}
+
+int
+nng_id_alloc(nng_id_map *map, uint64_t *id, void *val)
+{
+ return (nni_id_alloc(&map->m, id, val));
+}
+
+bool
+nng_id_visit(nng_id_map *map, uint64_t *id, void **valp, uint32_t *cursor)
+{
+ return (nni_id_visit(&map->m, id, valp, cursor));
+}
diff --git a/src/supplemental/util/CMakeLists.txt b/src/supplemental/util/CMakeLists.txt
index 69afd9e0..d7541363 100644
--- a/src/supplemental/util/CMakeLists.txt
+++ b/src/supplemental/util/CMakeLists.txt
@@ -7,9 +7,7 @@
# found online at https://opensource.org/licenses/MIT.
#
-nng_sources(idhash.c options.c)
+nng_sources(options.c)
nng_headers(
- nng/supplemental/util/idhash.h
nng/supplemental/util/options.h)
-nng_test(idhash_test)
nng_test(options_test)
diff --git a/src/supplemental/util/idhash.c b/src/supplemental/util/idhash.c
deleted file mode 100644
index 4ededa31..00000000
--- a/src/supplemental/util/idhash.c
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
-//
-// This software is supplied under the terms of the MIT License, a
-// copy of which should be located in the distribution where this
-// file was obtained (LICENSE.txt). A copy of the license may also be
-// found online at https://opensource.org/licenses/MIT.
-//
-
-#include <nng/nng.h>
-#include <nng/supplemental/util/idhash.h>
-
-#include "core/nng_impl.h"
-
-struct nng_id_map_s {
- nni_id_map m;
-};
-
-int
-nng_id_map_alloc(nng_id_map **map, uint64_t lo, uint64_t hi, int flags)
-{
- nng_id_map *m;
-
- if ((m = NNI_ALLOC_STRUCT(m)) == NULL) {
- return (NNG_ENOMEM);
- }
- nni_id_map_init(
- &m->m, lo, hi, (flags & NNG_MAP_RANDOM) ? true : false);
- *map = m;
- return (0);
-}
-
-void
-nng_id_map_free(nng_id_map *map)
-{
- nni_id_map_fini(&map->m);
- NNI_FREE_STRUCT(map);
-}
-
-void *
-nng_id_get(nng_id_map *map, uint64_t id)
-{
- return (nni_id_get(&map->m, id));
-}
-
-int
-nng_id_set(nng_id_map *map, uint64_t id, void *val)
-{
- return (nni_id_set(&map->m, id, val));
-}
-
-int
-nng_id_remove(nng_id_map *map, uint64_t id)
-{
- return (nni_id_remove(&map->m, id));
-}
-
-int
-nng_id_alloc(nng_id_map *map, uint64_t *id, void *val)
-{
- return (nni_id_alloc(&map->m, id, val));
-}
-
-bool
-nng_id_visit(nng_id_map *map, uint64_t *id, void **valp, uint32_t *cursor)
-{
- return (nni_id_visit(&map->m, id, valp, cursor));
-}