aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/MemoryGlobal.cpp
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2021-12-27 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2022-03-18 15:35:13 +0500
commitf19f813537c7aea1c20749c914e756b54a9c3cf5 (patch)
tree816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /CPP/Windows/MemoryGlobal.cpp
parent98e06a519b63b81986abe76d28887f6984a7732b (diff)
download7zip-21.07.tar.gz
7zip-21.07.tar.bz2
7zip-21.07.zip
'21.07'21.07
Diffstat (limited to 'CPP/Windows/MemoryGlobal.cpp')
-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}}