-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitmap.h
More file actions
29 lines (21 loc) · 730 Bytes
/
bitmap.h
File metadata and controls
29 lines (21 loc) · 730 Bytes
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
26
27
28
29
#pragma once
#include <stdint.h>
typedef struct{
int num_bits;
char* entries;
} BitMap;
typedef struct {
int entry_num;
char bit_num;
} BitMapEntryKey;
// converts a block index to an index in the array,
// and a char that indicates the offset of the bit inside the array
BitMapEntryKey BitMap_blockToIndex(int num);
// converts a bit to a linear index
int BitMap_indexToBlock(int entry, uint8_t bit_num);
// returns the index of the first bit having status "status"
// in the bitmap bmap, and starts looking from position start
int BitMap_get(BitMap* bmap, int start, int status);
// sets the bit at index pos in bmap to status
int BitMap_set(BitMap* bmap, int pos, int status);
void BitMap_print(BitMap* bmap);