#define BITMAP_NWORDS(_n) \
(((_n) + BITMAP_WORD_BITS - 1) / BITMAP_WORD_BITS)
+#define BITMAP_WORD_0 (0)
+#define BITMAP_WORD_1 ((bitmap_word)-1UL)
+
/*
* We wrap each word in a structure for type checking.
*/
-typedef struct {
+typedef struct bitmap {
bitmap_word w;
} bitmap;
return true;
}
+unsigned long bitmap_ffs(const bitmap *bitmap,
+ unsigned long n, unsigned long m);
+
/*
* Allocation functions
*/
bitmap *bitmap;
bitmap = bitmap_alloc(nbits);
- bitmap_zero(bitmap, nbits);
+ if (bitmap)
+ bitmap_zero(bitmap, nbits);
return bitmap;
}
bitmap *bitmap;
bitmap = bitmap_alloc(nbits);
- bitmap_fill(bitmap, nbits);
+ if (bitmap)
+ bitmap_fill(bitmap, nbits);
return bitmap;
}
{
bitmap = realloc(bitmap, bitmap_sizeof(nbits));
- if (nbits > obits)
+ if ((nbits > obits) && bitmap)
bitmap_zero_range(bitmap, obits, nbits);
return bitmap;
{
bitmap = realloc(bitmap, bitmap_sizeof(nbits));
- if (nbits > obits)
+ if ((nbits > obits) && bitmap)
bitmap_fill_range(bitmap, obits, nbits);
return bitmap;