blob: db9653a7158be2437070ac2ac8eafd9e3a330d26 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
|