VPP-166 Documentation changes for ip4.h/lookup.h
[vpp.git] / vppinfra / vppinfra / bitmap.h
index 986c322..35de1b4 100644 (file)
@@ -45,6 +45,8 @@
 #include <vppinfra/error.h>
 #include <vppinfra/bitops.h>   /* for count_set_bits */
 
+typedef uword clib_bitmap_t;
+
 /* Returns 1 if the entire bitmap is zero, 0 otherwise */
 always_inline uword
 clib_bitmap_is_zero (uword * ai)
@@ -345,14 +347,14 @@ always_inline uword clib_bitmap_last_set (uword * ai)
 {
   uword i;
 
-  for (i = vec_len (ai) - 1; i >= 0 ; i--)
+  for (i = vec_len (ai); i > 0 ; i--)
     {
-      uword x = ai[i];
+      uword x = ai[i - 1];
       if (x != 0)
        {
          uword first_bit;
          count_leading_zeros (first_bit, x);
-         return (i + 1) * BITS (ai[0]) - first_bit - 1;
+         return (i) * BITS (ai[0]) - first_bit - 1;
        }
     }
   return ~0;