diff mbox series

[ovs-dev,v5,1/3] id-pool: Add interface to check if id has been allocated

Message ID 20200904142739.26353-1-mark.d.gray@redhat.com
State Changes Requested
Headers show
Series [ovs-dev,v5,1/3] id-pool: Add interface to check if id has been allocated | expand

Commit Message

Mark Gray Sept. 4, 2020, 2:27 p.m. UTC
Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
---
 lib/id-pool.c | 10 ++++++++++
 lib/id-pool.h |  1 +
 2 files changed, 11 insertions(+)
diff mbox series

Patch

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.