malloc_size alternative on Linux and Windows

c, gcc, linux, malloc, windows

Solution

On Windows, things that use the MS CRT can use _msize, on Linux you could try malloc_usable_size...

Problem

How can one tell, given a `void *` pointer, what is the size of a block allocated on this given address (previously allocated using `malloc`; in Linux and Windows)? I hope both systems surely store this kind of information somewhere. That is, alternative of `malloc_size` which exists on OSX/Darwin. Using gcc/mingw if it helps.

Original source

Related problems