mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-14 16:11:38 -06:00
3.13
This commit is contained in:
59
Windows/Memory.cpp
Executable file
59
Windows/Memory.cpp
Executable file
@@ -0,0 +1,59 @@
|
||||
// Windows/Memory.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Windows/Memory.h"
|
||||
|
||||
namespace NWindows {
|
||||
namespace NMemory {
|
||||
|
||||
CGlobal::~CGlobal()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
// aFlags = GMEM_MOVEABLE
|
||||
bool CGlobal::Alloc(UINT aFlags, DWORD aSize)
|
||||
{
|
||||
HGLOBAL aNewBlock = ::GlobalAlloc(aFlags, aSize);
|
||||
if (aNewBlock == NULL)
|
||||
return false;
|
||||
m_MemoryHandle = aNewBlock;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGlobal::Free()
|
||||
{
|
||||
if (m_MemoryHandle == NULL)
|
||||
return true;
|
||||
m_MemoryHandle = ::GlobalFree(m_MemoryHandle);
|
||||
return (m_MemoryHandle == NULL);
|
||||
}
|
||||
|
||||
HGLOBAL CGlobal::Detach()
|
||||
{
|
||||
HGLOBAL aHandle = m_MemoryHandle;
|
||||
m_MemoryHandle = NULL;
|
||||
return aHandle;
|
||||
}
|
||||
|
||||
LPVOID CGlobal::Lock() const
|
||||
{
|
||||
return ::GlobalLock(m_MemoryHandle);
|
||||
}
|
||||
|
||||
void CGlobal::Unlock() const
|
||||
{
|
||||
::GlobalUnlock(m_MemoryHandle);
|
||||
}
|
||||
|
||||
bool CGlobal::ReAlloc(DWORD aSize)
|
||||
{
|
||||
HGLOBAL aNewBlock = ::GlobalReAlloc(m_MemoryHandle, aSize, GMEM_MOVEABLE);
|
||||
if (aNewBlock == NULL)
|
||||
return false;
|
||||
m_MemoryHandle = aNewBlock;
|
||||
return true;
|
||||
}
|
||||
|
||||
}}
|
||||
Reference in New Issue
Block a user