mem.cpp
来自「The Bit Array structure provides a compa」· C++ 代码 · 共 40 行
CPP
40 行
// mem.cpp: implementation
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "malloc.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#endif
//////////////////////////////////////////////////////////////////////
void *AllocPtr(int nSize)
{
void *p = malloc(nSize);
nSize = _msize(p);
memset(p, 0, nSize);
return p;
}
void *ReAllocPtr(void *p, int nSize)
{
int nOldSize = _msize(p);
p = realloc(p, nSize);
if(nSize > nOldSize)
{
nSize = _msize(p);
memset((char*)p+nOldSize, 0, nSize-nOldSize);
}
return p;
}
void FreePtr(void *p)
{
free(p);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?