How can I get, given a pointer to a block of memory allocated with malloc, the size of it?
For example:
void* ptr = malloc( 10 ); //Allocate 10 bytes
printf( "%d", GetMemSize( ptr ) ); //Should print 10
I want to do this for debugging purposes.
In Visual C++ you can use _msize()
for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With