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.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/hicn-light/src/hicn/base/bitmap.h b/hicn-light/src/hicn/base/bitmap.h
index 908b28d87..46d473ff8 100644
--- a/hicn-light/src/hicn/base/bitmap.h
+++ b/hicn-light/src/hicn/base/bitmap.h
@@ -66,6 +66,13 @@ bitmap_ensure_pos(bitmap_t ** bitmap, off_t pos)
}
/**
+ * @brief Returns the allocated size of a bitmap.
+ *
+ * @see listener_table_get_by_id
+ */
+#define bitmap_get_alloc_size(bitmap) vector_get_alloc_size(bitmap)
+
+/**
* @brief Retrieve the state of the i-th bit in the bitmap.
*
* @param[in] bitmap The bitmap to access.
@@ -76,6 +83,7 @@ int
bitmap_get(const bitmap_t * bitmap, off_t i)
{
size_t offset = i / BITMAP_WIDTH(bitmap);
+ assert(offset < bitmap_get_alloc_size(bitmap));
size_t pos = i % BITMAP_WIDTH(bitmap);
size_t shift = BITMAP_WIDTH(bitmap) - pos - 1;
return (bitmap[offset] >> shift) & 1;
@@ -197,8 +205,4 @@ END:
#define bitmap_free(bitmap) vector_free(bitmap)
-#ifdef WITH_TESTS
-#define bitmap_get_alloc_size(bitmap) vector_get_alloc_size(bitmap)
-#endif /* WITH_TESTS */
-
#endif /* UTIL_BITMAP_H */