From: Tianyu Yuan <[email protected]>

Add helper function to add id_node in hmap directly and
expose this function for external use.

Signed-off-by: Tianyu Yuan <[email protected]>
Signed-off-by: Simon Horman <[email protected]>
---
 lib/id-pool.c | 12 ++++++++++--
 lib/id-pool.h |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/id-pool.c b/lib/id-pool.c
index 97b7185ed538..5c6dab906922 100644
--- a/lib/id-pool.c
+++ b/lib/id-pool.c
@@ -87,14 +87,22 @@ id_pool_find(struct id_pool *pool, uint32_t id)
 }
 
 void
-id_pool_add(struct id_pool *pool, uint32_t id)
+id_hmap_add(struct hmap *map, uint32_t id)
 {
     struct id_node *id_node = xmalloc(sizeof *id_node);
     size_t hash;
 
     id_node->id = id;
     hash = hash_int(id, 0);
-    hmap_insert(&pool->map, &id_node->node, hash);
+    hmap_insert(map, &id_node->node, hash);
+}
+
+void
+id_pool_add(struct id_pool *pool, uint32_t id)
+{
+    struct hmap *map = &pool->map;
+
+    id_hmap_add(map, id);
 }
 
 bool
diff --git a/lib/id-pool.h b/lib/id-pool.h
index f71cc570f104..9fcd2c188666 100644
--- a/lib/id-pool.h
+++ b/lib/id-pool.h
@@ -35,6 +35,7 @@ struct id_pool *id_pool_create(uint32_t base, uint32_t n_ids);
 void id_pool_destroy(struct id_pool *);
 bool id_pool_alloc_id(struct id_pool *, uint32_t *id);
 void id_pool_free_id(struct id_pool *, uint32_t id);
+void id_hmap_add(struct hmap *map, uint32_t id);
 void id_pool_add(struct id_pool *, uint32_t id);
 
 /*
-- 
2.30.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to