Visual Studio 2010 C++:获取 malloc 分配的内存块大小
问题描述:
给定一个指向使用 malloc 分配的内存块的指针,我如何获得它的大小?
How can I get, given a pointer to a block of memory allocated with malloc, the size of it?
例如:
void* ptr = malloc( 10 ); //Allocate 10 bytes
printf( "%d", GetMemSize( ptr ) ); //Should print 10
我想这样做是为了调试目的.
I want to do this for debugging purposes.