7#ifndef __MY_MEM_TOOLS_H__
8#define __MY_MEM_TOOLS_H__
10#define MY_HEAP_FLAG_USED 0x00000001
11#define MY_HEAP_FLAG_LEN_MASK 0xfffffffe
13#define MyFreeMemoryAndPointer(ptr) \
25#ifdef MY_HEAP_TRACK_OWNERS
29#ifdef MY_HEAP_TRACK_REF
45#define MY_HEAP_FRAME_SIZE (256*1024)
46#define MY_HEAP_MAX_FRAMES 512
47#define MY_HEAP_MAX_BLOCKS 4*1024
49#ifdef USE_THREAD_HEAPS
51extern "C" VOID ExInitThreadPools();
52extern "C" VOID ExDeInitThreadPools();
53extern "C" VOID ExFreeThreadPool();
59#ifdef MY_HEAP_TRACK_OWNERS
61 #ifdef MY_HEAP_TRACK_REF
68 #ifdef MY_HEAP_TRACK_REF
76#ifdef MY_HEAP_CHECK_BOUNDS
77 #define MY_HEAP_ALIGN 63
79 #define MY_HEAP_ALIGN 63
81#define PAGE_SIZE_ALIGN (PAGE_SIZE - 1)
83#define AlignToPageSize(size) (((size)+PAGE_SIZE_ALIGN)&(~PAGE_SIZE_ALIGN))
84#define MyAlignSize__(size) (((size)+MY_HEAP_ALIGN)&(~MY_HEAP_ALIGN))
85#ifdef MY_HEAP_FORCE_NONPAGED
86#define MyFixMemType(type) NonPagedPool
88#define MyFixMemType(type) (type)
91#ifdef MY_USE_INTERNAL_MEMMANAGER
93#ifdef MY_HEAP_TRACK_OWNERS
94 #ifdef MY_HEAP_TRACK_REF
95 #define MyAllocatePool__(type,size) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__, NULL)
96 #define MyAllocatePoolTag__(type,size,tag) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__, (PCHAR)(tag))
98 #define MyAllocatePool__(type,size) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__)
99 #define MyAllocatePoolTag__(type,size,tag) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__)
102 #ifdef MY_HEAP_TRACK_REF
103 #define MyAllocatePool__(type,size) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size), NULL)
104 #define MyAllocatePoolTag__(type,size,tag) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size), (PCHAR)(tag))
106 #define MyAllocatePool__(type,size) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size))
107 #define MyAllocatePoolTag__(type,size,tag) MyAllocatePool(MyFixMemType(type), MyAlignSize__(size))
111#define MyFreePool__(addr) MyFreePool((PCHAR)(addr))
113#ifdef MY_HEAP_TRACK_OWNERS
114#define MyReallocPool__(addr, len, pnewaddr, newlen) MyReallocPool((PCHAR)(addr), MyAlignSize__(len), pnewaddr, MyAlignSize__(newlen), UDF_BUG_CHECK_ID, __LINE__)
116#define MyReallocPool__(addr, len, pnewaddr, newlen) MyReallocPool((PCHAR)(addr), MyAlignSize__(len), pnewaddr, MyAlignSize__(newlen))
125#define MyCheckArray(base, index) \
126 ASSERT(MyFindMemBaseByAddr((PCHAR)(base)) == MyFindMemBaseByAddr((PCHAR)(base+(index))))
129#define MyCheckArray(base, index)
137#define MyAlignSize__(size) (size)
141#define MyAllocRelease()
143#ifndef MY_MEM_BOUNDS_CHECK
145 #ifdef TRACK_SYS_ALLOC_CALLERS
146 #define MyAllocatePool__(type,size) DebugAllocatePool(NonPagedPool,MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__)
147 #define MyAllocatePoolTag__(type,size,tag) DebugAllocatePool(NonPagedPool,MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__)
149 #define MyAllocatePool__(type,size) DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), 'fNWD')
150 #define MyAllocatePoolTag__(type,size,tag) DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), tag)
152 #define MyFreePool__(addr) DbgFreePool((PCHAR)(addr))
156 #ifdef TRACK_SYS_ALLOC_CALLERS
157 #define MyAllocatePool_(type,size) DebugAllocatePool(NonPagedPool,MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__)
158 #define MyAllocatePoolTag_(type,size,tag) DebugAllocatePool(NonPagedPool,MyAlignSize__(size), UDF_BUG_CHECK_ID, __LINE__)
160 #define MyAllocatePool_(type,size) DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), 'mNWD')
161 #define MyAllocatePoolTag_(type,size,tag) DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), tag)
163 #define MyFreePool_(addr) DbgFreePool((PCHAR)(addr))
165#define MyAllocatePool__(type,size) MyAllocatePoolTag__(type,size,'mNWD')
190#ifdef TRACK_SYS_ALLOC_CALLERS
219 MyFreePool_(newaddr);
225#if defined(__GNUC__) && !defined(__clang__)
226#pragma GCC diagnostic push
227#pragma GCC diagnostic ignored "-Wstringop-overflow"
238#ifdef MY_MEM_BOUNDS_CHECK
249 if ((_newlen != _len)
250#ifdef MY_MEM_BOUNDS_CHECK
254#ifdef TRACK_SYS_ALLOC_CALLERS
264#ifdef MY_MEM_BOUNDS_CHECK
266 newaddr[newlen+
i] = (
UCHAR)(
'A'+
i);
270 if(_newlen <= _len) {
276#ifdef MY_MEM_BOUNDS_CHECK
301#if defined(__GNUC__) && !defined(__clang__)
302#pragma GCC diagnostic pop
307#define MyAlignSize__(size) (((size)+MY_HEAP_ALIGN)&(~MY_HEAP_ALIGN))
310#define MyCheckArray(base, index)
static USHORT USHORT * NewLength
GLuint GLuint GLsizei GLenum type
GLenum const GLvoid * addr
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void __cdecl __debugbreak(void)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag