chiark / gitweb /
[PATCH] update klibc to version 0.181
[elogind.git] / klibc / klibc / malloc.h
1 /*
2  * malloc.h
3  *
4  * Internals for the memory allocator
5  */
6
7 #include <stdint.h>
8 #include <stddef.h>
9 #include <klibc/sysconfig.h>
10
11 /*
12  * This structure should be a power of two.  This becomes the
13  * alignment unit.
14  */
15 struct free_arena_header;
16
17 struct arena_header {
18   size_t type;
19   size_t size;                  /* Also gives the location of the next entry */
20   struct free_arena_header *next, *prev;
21 };
22
23 #ifdef DEBUG_MALLOC
24 #define ARENA_TYPE_USED 0x64e69c70
25 #define ARENA_TYPE_FREE 0x012d610a
26 #define ARENA_TYPE_HEAD 0x971676b5
27 #define ARENA_TYPE_DEAD 0xeeeeeeee
28 #else
29 #define ARENA_TYPE_USED 0
30 #define ARENA_TYPE_FREE 1
31 #define ARENA_TYPE_HEAD 2
32 #endif
33
34 #define ARENA_SIZE_MASK (~(sizeof(struct arena_header)-1))
35
36 /*
37  * This structure should be no more than twice the size of the
38  * previous structure.
39  */
40 struct free_arena_header {
41   struct arena_header a;
42   struct free_arena_header *next_free, *prev_free;
43 };
44
45 extern struct free_arena_header __malloc_head;