Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

malloc_size alternative on Linux and Windows

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.

like image 398
Cartesius00 Avatar asked Jun 09 '12 08:06

Cartesius00


1 Answers

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

like image 187
Anders Avatar answered Oct 13 '22 22:10

Anders