summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2021-10-25 09:06:48 +0000
committerDamjan Marion <dmarion@me.com>2021-10-28 10:59:16 +0000
commitc19ac303404966433096c4855a8192f746973522 (patch)
tree226d1c5bb6498268ad5002154f46dd0b24261ddc /src/vppinfra
parent5d8072c059eda181b54d5ad425abc6f8edaf2a31 (diff)
vppinfra: A bitmap copy function
Type: improvement Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: Id7a7788b41dbcf280e025e5256c41729b0c95f39
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/bitmap.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h
index 92205bfc8e8..af651ef0b7e 100644
--- a/src/vppinfra/bitmap.h
+++ b/src/vppinfra/bitmap.h
@@ -115,6 +115,24 @@ clib_bitmap_is_equal (uword * a, uword * b)
#define clib_bitmap_validate(v,n_bits) \
clib_bitmap_vec_validate ((v), ((n_bits) - 1) / BITS (uword))
+/** Copy a bitmap
+ @param dst - copy to
+ @param src - copy from
+*/
+static_always_inline void
+clib_bitmap_copy (clib_bitmap_t **dst, const clib_bitmap_t *src)
+{
+ if (vec_len (src))
+ {
+ clib_bitmap_vec_validate (*dst, vec_len (src) - 1);
+ vec_copy (*dst, src);
+ }
+ else
+ {
+ vec_reset_length (*dst);
+ }
+}
+
/* low-level routine to remove trailing zeros from a bitmap */
always_inline uword *
_clib_bitmap_remove_trailing_zeros (uword * a)