4 * Internals for the memory allocator
11 * This is the minimum chunk size we will ask the kernel for; this should
12 * be a multiple of the page size on all architectures.
14 #define MALLOC_CHUNK_SIZE 65536
15 #define MALLOC_CHUNK_MASK (MALLOC_CHUNK_SIZE-1)
18 * This structure should be a power of two. This becomes the
21 struct free_arena_header
;
25 size_t size
; /* Also gives the location of the next entry */
26 struct free_arena_header
*next
, *prev
;
30 #define ARENA_TYPE_USED 0x64e69c70
31 #define ARENA_TYPE_FREE 0x012d610a
32 #define ARENA_TYPE_HEAD 0x971676b5
33 #define ARENA_TYPE_DEAD 0xeeeeeeee
35 #define ARENA_TYPE_USED 0
36 #define ARENA_TYPE_FREE 1
37 #define ARENA_TYPE_HEAD 2
40 #define ARENA_SIZE_MASK (sizeof(struct arena_header)-1)
42 #define ARENA_ALIGN_UP(p) ((char *)(((uintptr_t)(p) + ARENA_SIZE_MASK) & ~ARENA_SIZE_MASK))
43 #define ARENA_ALIGN_DOWN(p) ((char *)((uintptr_t)(p) & ~ARENA_SIZE_MASK))
46 * This structure should be no more than twice the size of the
49 struct free_arena_header
{
50 struct arena_header a
;
51 struct free_arena_header
*next_free
, *prev_free
;
54 extern struct free_arena_header __malloc_head
;