aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/base/bitmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-light/src/hicn/base/bitmap.h')
-rw-r--r--hicn-light/src/hicn/base/bitmap.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/hicn-light/src/hicn/base/bitmap.h b/hicn-light/src/hicn/base/bitmap.h
index 1159806c8..908b28d87 100644
--- a/hicn-light/src/hicn/base/bitmap.h
+++ b/hicn-light/src/hicn/base/bitmap.h
@@ -100,16 +100,27 @@ bitmap_get(const bitmap_t * bitmap, off_t i)
*
* @return bool
*/
+#define bitmap_set(bitmap, i) \
+ _bitmap_set((bitmap_t**)&bitmap, i)
+
+/*
+ * @brief Returns whether the i-th bit is unset (equal to 0) in a bitmap (helper).
+ *
+ * @param[in] bitmap The bitmap to access.
+ * @param[in] i The bit position.
+ *
+ * @return bool
+ */
static inline
int
-bitmap_set(bitmap_t * bitmap, off_t i)
+_bitmap_set(bitmap_t ** bitmap, off_t i)
{
- if (bitmap_ensure_pos(&bitmap, i) < 0)
+ if (bitmap_ensure_pos(bitmap, i) < 0)
return -1;
size_t offset = i / BITMAP_WIDTH(bitmap);
size_t pos = i % BITMAP_WIDTH(bitmap);
size_t shift = BITMAP_WIDTH(bitmap) - pos - 1;
- bitmap[offset] |= 1ul << shift;
+ (*bitmap)[offset] |= 1ul << shift;
return 0;
}