diff options
Diffstat (limited to 'src/malloc/mallocng/malloc_usable_size.c')
-rw-r--r-- | src/malloc/mallocng/malloc_usable_size.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/malloc/mallocng/malloc_usable_size.c b/src/malloc/mallocng/malloc_usable_size.c new file mode 100644 index 00000000..a440a4ea --- /dev/null +++ b/src/malloc/mallocng/malloc_usable_size.c @@ -0,0 +1,12 @@ +#include <stdlib.h> +#include "meta.h" + +size_t malloc_usable_size(void *p) +{ + struct meta *g = get_meta(p); + int idx = get_slot_index(p); + size_t stride = get_stride(g); + unsigned char *start = g->mem->storage + stride*idx; + unsigned char *end = start + stride - IB; + return get_nominal_size(p, end); +} |