申请的内存布局_CrtMemBlockHeader +申请的可用内存+nNoMansLandSize(4)字节
_CrtMemBlockHeader放置申请的信息,包括申请的内存大小,_CrtMemBlockHeader中的gap和结尾的nNoMansLandSize被初始化为_bNoMansLandFill(0xFD),可用内存被初始化为_bCleanLandFill(0xCD)
// 获取申请的内存大小,win32平台,其他同理,未测试
#define nNoMansLandSize 4
typedef struct _CrtMemBlockHeader
{
struct _CrtMemBlockHeader * pBlockHeaderNext;
struct _CrtMemBlockHeader * pBlockHeaderPrev;
char * szFileName;
int nLine;
#ifdef _WIN64
/* These items are reversed on Win64 to eliminate gaps in the struct
* and ensure that sizeof(struct)%16 == 0, so 16-byte alignment is
* maintained in the debug heap.
*/
int nBlockUse;
size_t nDataSize;
#else /* _WIN64 */
size_t nDataSize;
int nBlockUse;
#endif /* _WIN64 */
long lRequest;
unsigned char gap[nNoMansLandSize];
/* followed by:
* unsigned char data[nDataSize];
* unsigned char anotherGap[nNoMansLandSize];
*/
} _CrtMemBlockHeader;
int mem_size = ((_CrtMemBlockHeader*)mPoints - 1)->nDataSize;