summaryrefslogtreecommitdiff
path: root/src/malloc/mallocng/malloc_usable_size.c
blob: a440a4eab2d39172d6e0358a2aec34b98e21aba3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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);
}