You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.1 KiB
68 lines
2.1 KiB
// --------------------------------------------------------------------------------
|
|
// Memutil.cpp
|
|
// This file is linked into other projects.
|
|
// --------------------------------------------------------------------------------
|
|
#include "pch.hxx"
|
|
|
|
// --------------------------------------------------------------------------------
|
|
// ZeroAllocate
|
|
// --------------------------------------------------------------------------------
|
|
LPVOID ZeroAllocate(DWORD cbSize)
|
|
{
|
|
LPVOID pv = g_pMalloc->Alloc(cbSize);
|
|
if (pv)
|
|
ZeroMemory(pv, cbSize);
|
|
return pv;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------
|
|
// MemAlloc
|
|
// --------------------------------------------------------------------------------
|
|
BOOL MemAlloc(LPVOID* ppv, ULONG cb)
|
|
{
|
|
Assert(ppv && cb);
|
|
*ppv = g_pMalloc->Alloc(cb);
|
|
if (NULL == *ppv)
|
|
return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------
|
|
// HrAlloc
|
|
// --------------------------------------------------------------------------------
|
|
HRESULT HrAlloc(LPVOID *ppv, ULONG cb)
|
|
{
|
|
Assert(ppv && cb);
|
|
*ppv = g_pMalloc->Alloc(cb);
|
|
if (NULL == *ppv)
|
|
return TrapError(E_OUTOFMEMORY);
|
|
return S_OK;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------
|
|
// MemRealloc
|
|
// --------------------------------------------------------------------------------
|
|
BOOL MemRealloc(LPVOID *ppv, ULONG cbNew)
|
|
{
|
|
Assert(ppv && cbNew);
|
|
LPVOID pv = g_pMalloc->Realloc(*ppv, cbNew);
|
|
if (NULL == pv)
|
|
return FALSE;
|
|
*ppv = pv;
|
|
return TRUE;
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------
|
|
// HrRealloc
|
|
// --------------------------------------------------------------------------------
|
|
HRESULT HrRealloc(LPVOID *ppv, ULONG cbNew)
|
|
{
|
|
Assert(ppv);
|
|
LPVOID pv = g_pMalloc->Realloc(*ppv, cbNew);
|
|
if (NULL == pv && 0 != cbNew)
|
|
return TrapError(E_OUTOFMEMORY);
|
|
*ppv = pv;
|
|
return S_OK;
|
|
}
|
|
|
|
// "new" and "delete" come from libcmt.lib
|