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