ReactOS 0.4.15-dev-8222-g9164419
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
8namespace ATL
9{
10
11//__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0"))
13{
14public:
15 virtual ~IAtlMemMgr() {};
16
18 _In_ size_t SizeBytes
19 ) = 0;
20
21 virtual void Free(
23 ) = 0;
24
28 ) = 0;
29
30 virtual size_t GetSize(
31 _In_ void* Buffer
32 ) = 0;
33};
34
35class CWin32Heap : public IAtlMemMgr
36{
37public:
39
40public:
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 {
62 return ::HeapAlloc(m_hHeap, 0, SizeBytes);
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
77 _In_opt_ void* Buffer,
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
92 return ::HeapReAlloc(m_hHeap, 0, Buffer, SizeBytes);
93 }
94
95 virtual size_t GetSize(
96 _Inout_ void* Buffer
97 )
98 {
99 return ::HeapSize(m_hHeap, 0, Buffer);
100 }
101};
102
103}
104
105#endif
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HANDLE m_hHeap
Definition: atlmem.h:38
virtual ~CWin32Heap()
Definition: atlmem.h:52
_Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) virtual void *Reallocate(_In_opt_ void *Buffer
_Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) virtual void *Allocate(_In_ size_t SizeBytes)
Definition: atlmem.h:58
virtual void Free(_In_opt_ void *Buffer)
Definition: atlmem.h:65
CWin32Heap(_In_ HANDLE hHeap)
Definition: atlmem.h:46
virtual size_t GetSize(_Inout_ void *Buffer)
Definition: atlmem.h:95
_Ret_maybenull_ _In_ size_t SizeBytes
Definition: atlmem.h:80
virtual size_t GetSize(_In_ void *Buffer)=0
virtual ~IAtlMemMgr()
Definition: atlmem.h:15
virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void *Allocate(_In_ size_t SizeBytes)=0
virtual _Ret_maybenull_ _In_ size_t SizeBytes
Definition: atlmem.h:28
virtual void Free(_Inout_opt_ void *Buffer)=0
virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void *Reallocate(_Inout_updates_bytes_opt_(SizeBytes) void *Buffer
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define HeapFree(x, y, z)
Definition: compat.h:735
#define _Inout_
Definition: ms_sal.h:378
#define _Ret_maybenull_
Definition: ms_sal.h:529
#define _Inout_updates_bytes_opt_(size)
Definition: ms_sal.h:400
#define _Inout_opt_
Definition: ms_sal.h:379
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
Definition: rosdlgs.h:6
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815