xref: /aosp_15_r20/external/lzma/CPP/Windows/MemoryGlobal.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // Windows/MemoryGlobal.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "MemoryGlobal.h"
6 
7 namespace NWindows {
8 namespace NMemory {
9 
Alloc(UINT flags,SIZE_T size)10 bool CGlobal::Alloc(UINT flags, SIZE_T size) throw()
11 {
12   HGLOBAL newBlock = ::GlobalAlloc(flags, size);
13   if (newBlock == NULL)
14     return false;
15   _global = newBlock;
16   return true;
17 }
18 
Free()19 bool CGlobal::Free() throw()
20 {
21   if (_global == NULL)
22     return true;
23   _global = ::GlobalFree(_global);
24   return (_global == NULL);
25 }
26 
ReAlloc(SIZE_T size)27 bool CGlobal::ReAlloc(SIZE_T size) throw()
28 {
29   HGLOBAL newBlock = ::GlobalReAlloc(_global, size, GMEM_MOVEABLE);
30   if (newBlock == NULL)
31     return false;
32   _global = newBlock;
33   return true;
34 }
35 
36 }}
37