For GNU glibc:
SYNOPSIS
#include <malloc.h>
size_t malloc_usable_size (void *ptr);
DESCRIPTION
The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to a block of memory allocated by malloc(3) or a related function.