mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 15:14:59 -06:00
37 lines
661 B
C++
Executable File
37 lines
661 B
C++
Executable File
// Windows/Memory.cpp
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "Windows/Memory.h"
|
|
|
|
namespace NWindows {
|
|
namespace NMemory {
|
|
|
|
bool CGlobal::Alloc(UINT flags, SIZE_T size)
|
|
{
|
|
HGLOBAL newBlock = ::GlobalAlloc(flags, size);
|
|
if (newBlock == NULL)
|
|
return false;
|
|
m_MemoryHandle = newBlock;
|
|
return true;
|
|
}
|
|
|
|
bool CGlobal::Free()
|
|
{
|
|
if (m_MemoryHandle == NULL)
|
|
return true;
|
|
m_MemoryHandle = ::GlobalFree(m_MemoryHandle);
|
|
return (m_MemoryHandle == NULL);
|
|
}
|
|
|
|
bool CGlobal::ReAlloc(SIZE_T size)
|
|
{
|
|
HGLOBAL newBlock = ::GlobalReAlloc(m_MemoryHandle, size, GMEM_MOVEABLE);
|
|
if (newBlock == NULL)
|
|
return false;
|
|
m_MemoryHandle = newBlock;
|
|
return true;
|
|
}
|
|
|
|
}}
|