summaryrefslogtreecommitdiffstats
path: root/src/idmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/idmap.c')
-rw-r--r--src/idmap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/idmap.c b/src/idmap.c
index b69b0333..da7f175c 100644
--- a/src/idmap.c
+++ b/src/idmap.c
@@ -154,6 +154,18 @@ unsigned int idmap_alloc(struct idmap *idmap)
return bit + idmap->min;
}
+void idmap_take(struct idmap *idmap, unsigned int id)
+{
+ unsigned int bit = id - idmap->min;
+ unsigned int offset;
+
+ if (bit >= idmap->size)
+ return;
+
+ offset = bit / BITS_PER_LONG;
+ idmap->bits[offset] |= 1 << (bit % BITS_PER_LONG);
+}
+
/*
* Allocate the next bit skipping the ids up to and including last. If there
* is no free ids until the max id is encountered, the counter is wrapped back