ReactOS  0.4.14-dev-49-gfb4591c
atlmem.h
Go to the documentation of this file.
1 #ifndef __ATLMEM_H__
2 #define __ATLMEM_H__
3 
4 #pragma once
5 #include "atlcore.h"
6 
7 
8 namespace ATL
9 {
10 
11 //__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0"))
13 {
14 public:
15  virtual ~IAtlMemMgr() {};
16 
18  _In_ size_t SizeBytes
19  ) = 0;
20 
21  virtual void Free(
22  _Inout_opt_ void* Buffer
23  ) = 0;
24 
25  virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Reallocate(
27  _In_ size_t SizeBytes
28  ) = 0;
29 
30  virtual size_t GetSize(
31  _In_ void* Buffer
32  ) = 0;
33 };
34 
35 class CWin32Heap : public IAtlMemMgr
36 {
37 public:
39 
40 public:
42  m_hHeap(NULL)
43  {
44  }
45 
47  m_hHeap(hHeap)
48  {
49  ATLASSERT(hHeap != NULL);
50  }
51 
52  virtual ~CWin32Heap()
53  {
54  }
55 
56 
57  // IAtlMemMgr
59  _In_ size_t SizeBytes
60  )
61  {
63  }
64 
65  virtual void Free(
66  _In_opt_ void* Buffer
67  )
68  {
69  if (Buffer)
70  {
71  if (!::HeapFree(m_hHeap, 0, Buffer))
73  }
74  }
75 
76  _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) virtual void* Reallocate(
77  _In_opt_ void* Buffer,
78  _In_ size_t SizeBytes
79  )
80  {
81  if (SizeBytes == 0)
82  {
83  Free(Buffer);
84  return NULL;
85  }
86 
87  if (Buffer == NULL)
88  {
89  return Allocate(SizeBytes);
90  }
91 
93  }
94 
95  virtual size_t GetSize(
96  _Inout_ void* Buffer
97  )
98  {
100  }
101 };
102 
103 }
104 
105 #endif
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
virtual ~CWin32Heap()
Definition: atlmem.h:52
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
#define _In_opt_
Definition: no_sal2.h:213
virtual size_t GetSize(_Inout_ void *Buffer)
Definition: atlmem.h:95
#define _Inout_updates_bytes_opt_(size)
Definition: no_sal2.h:290
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
virtual ~IAtlMemMgr()
Definition: atlmem.h:15
virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void *Allocate(_In_ size_t SizeBytes)=0
CWin32Heap(_In_ HANDLE hHeap)
Definition: atlmem.h:46
Definition: rosdlgs.h:5
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
virtual void Free(_Inout_opt_ void *Buffer)=0
#define _Ret_maybenull_
Definition: no_sal2.h:590
_Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) virtual void *Allocate(_In_ size_t SizeBytes)
Definition: atlmem.h:58
#define _Inout_
Definition: no_sal2.h:244
virtual size_t GetSize(_In_ void *Buffer)=0
#define _In_
Definition: no_sal2.h:204
#define HeapReAlloc
Definition: compat.h:393
_Ret_maybenull_ _In_ size_t SizeBytes
Definition: atlmem.h:80
virtual void Free(_In_opt_ void *Buffer)
Definition: atlmem.h:65
virtual _Ret_maybenull_ _In_ size_t SizeBytes
Definition: atlmem.h:28
#define HeapFree(x, y, z)
Definition: compat.h:394
#define _Inout_opt_
Definition: no_sal2.h:258
HANDLE m_hHeap
Definition: atlmem.h:38