1 /* 2 malloc_usable_size - fully inspired by musl implementation 3 */ 4 5 #include "malloc.h" 6 7 /* for malloc_usable_size */ 8 #define OVERHEAD (2*sizeof(size_t)) 9 #define CHUNK_SIZE(c) ((c)->size & -2) 10 #define MEM_TO_CHUNK(p) (struct malloc_chunk *)((char *)(p) - OVERHEAD) 11 malloc_usable_size(void * p)12size_t malloc_usable_size(void *p) { 13 return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0; 14 } 15