[ovs-dev] [PATCH v6 1/2] id-pool: Add interface to check if id has been allocated

Mark Gray mark.d.gray at redhat.com
Mon Sep 7 08:37:54 UTC 2020


Signed-off-by: Mark Gray <mark.d.gray at redhat.com>
---
 lib/id-pool.c | 10 ++++++++++
 lib/id-pool.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/lib/id-pool.c b/lib/id-pool.c
index 69910ad08..bef822f6b 100644
--- a/lib/id-pool.c
+++ b/lib/id-pool.c
@@ -93,6 +93,16 @@ id_pool_find(struct id_pool *pool, uint32_t id)
     return NULL;
 }
 
+bool
+id_pool_has_id(struct id_pool *pool, uint32_t id)
+{
+    if (!id_pool_find(pool, id)) {
+        return false;
+    }
+
+    return true;
+}
+
 void
 id_pool_add(struct id_pool *pool, uint32_t id)
 {
diff --git a/lib/id-pool.h b/lib/id-pool.h
index 8721f8793..62876e2a5 100644
--- a/lib/id-pool.h
+++ b/lib/id-pool.h
@@ -29,6 +29,7 @@ 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_pool_add(struct id_pool *, uint32_t id);
+bool id_pool_has_id(struct id_pool *, uint32_t id);
 
 /*
  * ID pool.
-- 
2.26.2



More information about the dev mailing list