1370b324cSopenharmony_ci// Windows/MemoryGlobal.cpp
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#include "StdAfx.h"
4370b324cSopenharmony_ci
5370b324cSopenharmony_ci#include "MemoryGlobal.h"
6370b324cSopenharmony_ci
7370b324cSopenharmony_cinamespace NWindows {
8370b324cSopenharmony_cinamespace NMemory {
9370b324cSopenharmony_ci
10370b324cSopenharmony_cibool CGlobal::Alloc(UINT flags, SIZE_T size) throw()
11370b324cSopenharmony_ci{
12370b324cSopenharmony_ci  HGLOBAL newBlock = ::GlobalAlloc(flags, size);
13370b324cSopenharmony_ci  if (newBlock == NULL)
14370b324cSopenharmony_ci    return false;
15370b324cSopenharmony_ci  _global = newBlock;
16370b324cSopenharmony_ci  return true;
17370b324cSopenharmony_ci}
18370b324cSopenharmony_ci
19370b324cSopenharmony_cibool CGlobal::Free() throw()
20370b324cSopenharmony_ci{
21370b324cSopenharmony_ci  if (_global == NULL)
22370b324cSopenharmony_ci    return true;
23370b324cSopenharmony_ci  _global = ::GlobalFree(_global);
24370b324cSopenharmony_ci  return (_global == NULL);
25370b324cSopenharmony_ci}
26370b324cSopenharmony_ci
27370b324cSopenharmony_cibool CGlobal::ReAlloc(SIZE_T size) throw()
28370b324cSopenharmony_ci{
29370b324cSopenharmony_ci  HGLOBAL newBlock = ::GlobalReAlloc(_global, size, GMEM_MOVEABLE);
30370b324cSopenharmony_ci  if (newBlock == NULL)
31370b324cSopenharmony_ci    return false;
32370b324cSopenharmony_ci  _global = newBlock;
33370b324cSopenharmony_ci  return true;
34370b324cSopenharmony_ci}
35370b324cSopenharmony_ci
36370b324cSopenharmony_ci}}
37