Allocate enough memory so that the returned pointer can be safely
accessed as an array of unsigned long.
The actual bitmap size in units of bytes, as returned by bitmap_size,
remains unchanged.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Wei Liu <wl@xen.org>
static inline void *bitmap_alloc(unsigned long nr_bits)
{
- return calloc(1, bitmap_size(nr_bits));
+ unsigned long longs;
+
+ longs = (nr_bits + BITS_PER_LONG - 1) / BITS_PER_LONG;
+ return calloc(longs, sizeof(unsigned long));
}
static inline void bitmap_set(void *addr, unsigned long nr_bits)