vppinfra: make _vec_len() read-only
[vpp.git] / src / vppinfra / bitmap.h
index 096d3f1..02f9c7e 100644 (file)
@@ -142,7 +142,7 @@ _clib_bitmap_remove_trailing_zeros (uword * a)
       for (i = _vec_len (a) - 1; i >= 0; i--)
        if (a[i] != 0)
          break;
-      _vec_len (a) = i + 1;
+      vec_set_len (a, i + 1);
     }
   return a;
 }
@@ -518,29 +518,32 @@ always_inline uword *clib_bitmap_or (uword * ai, uword * bi);
 always_inline uword *clib_bitmap_xor (uword * ai, uword * bi);
 
 /* ALU function definition macro for functions taking two bitmaps. */
-#define _(name, body, check_zero)                              \
-always_inline uword *                                          \
-clib_bitmap_##name (uword * ai, uword * bi)                    \
-{                                                              \
-  uword i, a, b, bi_len, n_trailing_zeros;                     \
-                                                               \
-  n_trailing_zeros = 0;                                                \
-  bi_len = vec_len (bi);                                       \
-  if (bi_len > 0)                                              \
-    clib_bitmap_vec_validate (ai, bi_len - 1);                 \
-  for (i = 0; i < vec_len (ai); i++)                           \
-    {                                                          \
-      a = ai[i];                                               \
-      b = i < bi_len ? bi[i] : 0;                              \
-      do { body; } while (0);                                  \
-      ai[i] = a;                                               \
-      if (check_zero)                                          \
-       n_trailing_zeros = a ? 0 : (n_trailing_zeros + 1);      \
-    }                                                          \
-  if (check_zero)                                              \
-    _vec_len (ai) -= n_trailing_zeros;                         \
-  return ai;                                                   \
-}
+#define _(name, body, check_zero)                                             \
+  always_inline uword *clib_bitmap_##name (uword *ai, uword *bi)              \
+  {                                                                           \
+    uword i, a, b, bi_len, n_trailing_zeros;                                  \
+                                                                              \
+    n_trailing_zeros = 0;                                                     \
+    bi_len = vec_len (bi);                                                    \
+    if (bi_len > 0)                                                           \
+      clib_bitmap_vec_validate (ai, bi_len - 1);                              \
+    for (i = 0; i < vec_len (ai); i++)                                        \
+      {                                                                       \
+       a = ai[i];                                                            \
+       b = i < bi_len ? bi[i] : 0;                                           \
+       do                                                                    \
+         {                                                                   \
+           body;                                                             \
+         }                                                                   \
+       while (0);                                                            \
+       ai[i] = a;                                                            \
+       if (check_zero)                                                       \
+         n_trailing_zeros = a ? 0 : (n_trailing_zeros + 1);                  \
+      }                                                                       \
+    if (check_zero)                                                           \
+      vec_dec_len (ai, n_trailing_zeros);                                     \
+    return ai;                                                                \
+  }
 
 /* ALU functions: */
 /* *INDENT-OFF* */