blob: f6dc62dad4531ea8e324cad46b83dd4564e300be (
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
35
36
37
38
39
40
41
|
#ifndef KIT_ALLOCATOR_H
#define KIT_ALLOCATOR_H
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
enum { KIT_ALLOCATE, KIT_DEALLOCATE, KIT_REALLOCATE };
typedef void *(*kit_allocate_fn)(int request, void *state,
ptrdiff_t size,
ptrdiff_t previous_size,
void *pointer);
typedef struct {
void *state;
kit_allocate_fn allocate;
} kit_allocator_t;
/* Application should implement this function if custom allocator
* dispatch is enabled.
*
* See KIT_ENABLE_CUSTOM_ALLOC_DISPATCH macro.
*/
void *kit_alloc_dispatch(kit_allocator_t alloc, int request,
ptrdiff_t size, ptrdiff_t previous_size,
void *pointer);
kit_allocator_t kit_alloc_default(void);
#ifdef __cplusplus
}
#endif
#endif
|