diff options
Diffstat (limited to 'lib/bitmap.h')
| -rw-r--r-- | lib/bitmap.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/bitmap.h b/lib/bitmap.h new file mode 100644 index 0000000..db9653a --- /dev/null +++ b/lib/bitmap.h @@ -0,0 +1,25 @@ +#ifndef _JOVE_LIB_BITMAP_H +#define _JOVE_LIB_BITMAP_H 1 + +#include <stddef.h> +#include <stdbool.h> + +typedef unsigned char bitmap_block_t; +#define BITMAP_BLOCK_BITS (sizeof(bitmap_block_t) * 8) + +struct bitmap +{ + unsigned int total_bits; + unsigned int free_bits; + unsigned int last_free_bit; + bitmap_block_t data[]; +}; + +extern bool bitmap_check(struct bitmap *bitmap, size_t idx); +extern void bitmap_set(struct bitmap *bitmap, size_t idx); +extern void bitmap_unset(struct bitmap *bitmap, size_t idx); + +int bitmap_findfree(struct bitmap *bitmap); +int bitmap_findfree_contig(struct bitmap *bitmap, size_t size); + +#endif |
