memAlloc — выделение памяти
memRealloc — перераспределение памяти
memFree — освобождение памяти
memSize — размер блока памяти, 0 для NULL
например так
void * memAlloc(unsigned int size)
{
if (size > 0)
{
return HeapAlloc(hHeapMain,HEAP_ZERO_MEMORY,size);
}
else
{
return NULL;
}
}
//
void * memRealloc(void * lpMemory,unsigned int size)
{
if (lpMemory == NULL)
{
return memAlloc(size);
}
else
{
if (size == 0)
{
memFree(lpMemory);
return NULL;
}
else
{
return HeapReAlloc(hHeapMain,HEAP_ZERO_MEMORY,lpMemory,size);
}
}
}
//
#pragma warning(disable:4800)
//
bool memFree(void * lpMemory)
{
if (lpMemory != NULL)
{
return (bool)(HeapFree(hHeapMain,0,lpMemory));
}
else
{
return true;
}
}
//
unsigned int memSize(void * lpMemory)
{
return (lpMemory == NULL)?0:HeapSize(hHeapMain,0,lpMemory);
}