-
Notifications
You must be signed in to change notification settings - Fork 591
Expand file tree
/
Copy pathkbarena.h
More file actions
46 lines (36 loc) · 921 Bytes
/
kbarena.h
File metadata and controls
46 lines (36 loc) · 921 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef AC_KBARENA_H
#define AC_KBARENA_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Initialize a blocked arena
*
* @param blen block length in bytes
*
* @return pointer to a blocked arena
*/
void *kba_init(unsigned blen);
/** Destroy a blocked arena */
void kba_destroy(void *kba);
/**
* Allocate memory from a blocked arena
*
* @param len size of the memory to allocate
* @param aln alignment; must be power of 2
*
* @return pointer to the memory on success; NULL on insufficient memory or
* when len is longer than block length
*/
void *kba_alloc(void *kba, unsigned len, unsigned aln);
/** Save the state */
int kba_save(void *kba);
/** Restore the state (effectively free all memory allocated after the pairing save) */
int kba_restore(void *kba);
/** Get the capacity in byte */
size_t kba_capacity(const void *ba_);
#ifdef __cplusplus
}
#endif
#endif