bitvec: Add bitvec_bytes_used() function
This new bitvec API function returns the number of bytes used in a given
bit-vector.
Change-Id: Id4bd7f7543f5b0f4f6f876e283bd065039c37646
diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index c9bab39..da2d4e4 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -84,4 +84,13 @@
unsigned int array_len, bool dry_run,
unsigned int num_bits);
+/*! Return the number of bytes used within the bit vector */
+static inline unsigned int bitvec_used_bytes(const struct bitvec *bv)
+{
+ unsigned int bytes = bv->cur_bit/8;
+ if (bv->cur_bit%8)
+ bytes++;
+ return bytes;
+}
+
/*! @} */