aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/MemoryGlobal.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/Windows/MemoryGlobal.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/CPP/Windows/MemoryGlobal.cpp b/CPP/Windows/MemoryGlobal.cpp
new file mode 100644
index 0000000..2a22394
--- /dev/null
+++ b/CPP/Windows/MemoryGlobal.cpp
@@ -0,0 +1,36 @@
1// Windows/MemoryGlobal.cpp
2
3#include "StdAfx.h"
4
5#include "MemoryGlobal.h"
6
7namespace NWindows {
8namespace NMemory {
9
10bool 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
19bool CGlobal::Free() throw()
20{
21 if (_global == NULL)
22 return true;
23 _global = ::GlobalFree(_global);
24 return (_global == NULL);
25}
26
27bool 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}}