blob: 52f1fe500481e00a072923c82d345d8db6086b38 (
plain)
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
30
31
32
33
34
|
#ifndef foomemblockhfoo
#define foomemblockhfoo
#include <sys/types.h>
#include <inttypes.h>
enum memblock_type { MEMBLOCK_FIXED, MEMBLOCK_APPENDED, MEMBLOCK_DYNAMIC };
struct memblock {
enum memblock_type type;
unsigned ref;
size_t length;
void *data;
};
struct memchunk {
struct memblock *memblock;
size_t index, length;
};
struct memblock *memblock_new(size_t length);
struct memblock *memblock_new_fixed(void *data, size_t length);
struct memblock *memblock_new_dynamic(void *data, size_t length);
void memblock_unref(struct memblock*b);
struct memblock* memblock_ref(struct memblock*b);
void memblock_unref_fixed(struct memblock*b);
#define memblock_assert_exclusive(b) assert((b)->ref == 1)
extern unsigned n_blocks;
#endif
|