Changes in uspace/lib/c/generic/malloc.c [25f6bddb:ffccdff0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
r25f6bddb rffccdff0 35 35 36 36 #include <malloc.h> 37 #include <stdalign.h> 37 38 #include <stdbool.h> 38 39 #include <stddef.h> … … 81 82 (sizeof(heap_block_head_t) + sizeof(heap_block_foot_t)) 82 83 84 /** Calculate real size of a heap block. 85 * 86 * Add header and footer size. 87 * 88 */ 89 #define GROSS_SIZE(size) ((size) + STRUCT_OVERHEAD) 90 91 /** Calculate net size of a heap block. 92 * 93 * Subtract header and footer size. 94 * 95 */ 96 #define NET_SIZE(size) ((size) - STRUCT_OVERHEAD) 97 83 98 /** Overhead of each area. */ 84 99 #define AREA_OVERHEAD(size) \ 85 (ALIGN_UP(size + sizeof(heap_area_t), BASE_ALIGN)) 86 87 /** Calculate real size of a heap block. 88 * 89 * Add header and footer size. 90 * 91 */ 92 #define GROSS_SIZE(size) ((size) + STRUCT_OVERHEAD) 93 94 /** Calculate net size of a heap block. 95 * 96 * Subtract header and footer size. 97 * 98 */ 99 #define NET_SIZE(size) ((size) - STRUCT_OVERHEAD) 100 (ALIGN_UP(GROSS_SIZE(size) + sizeof(heap_area_t), BASE_ALIGN)) 100 101 101 102 /** Get first block in heap area. … … 198 199 199 200 #define malloc_assert(expr) safe_assert(expr) 201 202 /* 203 * Make sure the base alignment is sufficient. 204 */ 205 static_assert(BASE_ALIGN >= alignof(heap_area_t), ""); 206 static_assert(BASE_ALIGN >= alignof(heap_block_head_t), ""); 207 static_assert(BASE_ALIGN >= alignof(heap_block_foot_t), ""); 208 static_assert(BASE_ALIGN >= alignof(max_align_t), ""); 200 209 201 210 /** Serializes access to the heap from multiple threads. */
Note:
See TracChangeset
for help on using the changeset viewer.