ReactOS  0.4.13-dev-961-g238ea69
mem_tools.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MEM_ALLOC_DESC
 
struct  _MEM_FRAME_ALLOC_DESC
 

Macros

#define MY_HEAP_FLAG_USED   0x00000001
 
#define MY_HEAP_FLAG_LEN_MASK   0xfffffffe
 
#define MyFreeMemoryAndPointer(ptr)
 
#define MY_USE_ALIGN
 
#define MY_HEAP_FRAME_SIZE   (256*1024)
 
#define MY_HEAP_MAX_FRAMES   512
 
#define MY_HEAP_MAX_BLOCKS   4*1024
 
#define MY_HEAP_ALIGN   63
 
#define PAGE_SIZE_ALIGN   (PAGE_SIZE - 1)
 
#define AlignToPageSize(size)   (((size)+PAGE_SIZE_ALIGN)&(~PAGE_SIZE_ALIGN))
 
#define MyAlignSize__(size)   (((size)+MY_HEAP_ALIGN)&(~MY_HEAP_ALIGN))
 
#define MyFixMemType(type)   (type)
 
#define MyAllocRelease()
 
#define MyAllocatePool__(type, size)   DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), 'fNWD')
 
#define MyAllocatePoolTag__(type, size, tag)   DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), tag)
 
#define MyFreePool__(addr)   DbgFreePool((PCHAR)(addr))
 
#define MyCheckArray(base, index)
 

Typedefs

typedef struct _MEM_ALLOC_DESC MEM_ALLOC_DESC
 
typedef struct _MEM_ALLOC_DESCPMEM_ALLOC_DESC
 
typedef struct _MEM_FRAME_ALLOC_DESC MEM_FRAME_ALLOC_DESC
 
typedef struct _MEM_FRAME_ALLOC_DESCPMEM_FRAME_ALLOC_DESC
 

Functions

BOOLEAN MyAllocInit (VOID)
 
VOID MyAllocRelease (VOID)
 
PCHAR __fastcall MyAllocatePool (ULONG Type, ULONG size)
 
ULONG __fastcall MyReallocPool (PCHAR addr, ULONG OldLength, PCHAR *NewBuff, ULONG NewLength)
 
VOID __fastcall MyFreePool (PCHAR addr)
 
ULONG MyReallocPool__ (PCHAR addr, ULONG len, PCHAR *pnewaddr, ULONG newlen)
 

Variables

PCHAR BreakAddr
 
ULONG MemTotalAllocated
 

Macro Definition Documentation

◆ AlignToPageSize

#define AlignToPageSize (   size)    (((size)+PAGE_SIZE_ALIGN)&(~PAGE_SIZE_ALIGN))

Definition at line 83 of file mem_tools.h.

◆ MY_HEAP_ALIGN

#define MY_HEAP_ALIGN   63

Definition at line 79 of file mem_tools.h.

◆ MY_HEAP_FLAG_LEN_MASK

#define MY_HEAP_FLAG_LEN_MASK   0xfffffffe

Definition at line 11 of file mem_tools.h.

◆ MY_HEAP_FLAG_USED

#define MY_HEAP_FLAG_USED   0x00000001

Definition at line 10 of file mem_tools.h.

◆ MY_HEAP_FRAME_SIZE

#define MY_HEAP_FRAME_SIZE   (256*1024)

Definition at line 45 of file mem_tools.h.

◆ MY_HEAP_MAX_BLOCKS

#define MY_HEAP_MAX_BLOCKS   4*1024

Definition at line 47 of file mem_tools.h.

◆ MY_HEAP_MAX_FRAMES

#define MY_HEAP_MAX_FRAMES   512

Definition at line 46 of file mem_tools.h.

◆ MY_USE_ALIGN

#define MY_USE_ALIGN

Definition at line 19 of file mem_tools.h.

◆ MyAlignSize__

#define MyAlignSize__ (   size)    (((size)+MY_HEAP_ALIGN)&(~MY_HEAP_ALIGN))

Definition at line 84 of file mem_tools.h.

◆ MyAllocatePool__

#define MyAllocatePool__ (   type,
  size 
)    DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), 'fNWD')

Definition at line 149 of file mem_tools.h.

◆ MyAllocatePoolTag__

#define MyAllocatePoolTag__ (   type,
  size,
  tag 
)    DbgAllocatePoolWithTag(NonPagedPool,MyAlignSize__(size), tag)

Definition at line 150 of file mem_tools.h.

◆ MyAllocRelease

#define MyAllocRelease ( )

Definition at line 141 of file mem_tools.h.

◆ MyCheckArray

#define MyCheckArray (   base,
  index 
)

Definition at line 301 of file mem_tools.h.

◆ MyFixMemType

#define MyFixMemType (   type)    (type)

Definition at line 88 of file mem_tools.h.

◆ MyFreeMemoryAndPointer

#define MyFreeMemoryAndPointer (   ptr)
Value:
if(ptr) { \
MyFreePool__(ptr); \
ptr = NULL; \
}
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416

Definition at line 13 of file mem_tools.h.

◆ MyFreePool__

#define MyFreePool__ (   addr)    DbgFreePool((PCHAR)(addr))

Definition at line 152 of file mem_tools.h.

◆ PAGE_SIZE_ALIGN

#define PAGE_SIZE_ALIGN   (PAGE_SIZE - 1)

Definition at line 81 of file mem_tools.h.

Typedef Documentation

◆ MEM_ALLOC_DESC

◆ MEM_FRAME_ALLOC_DESC

◆ PMEM_ALLOC_DESC

◆ PMEM_FRAME_ALLOC_DESC

Function Documentation

◆ MyAllocatePool()

PCHAR __fastcall MyAllocatePool ( ULONG  Type,
ULONG  size 
)

◆ MyAllocInit()

BOOLEAN MyAllocInit ( VOID  )
inline

Definition at line 140 of file mem_tools.h.

140 {return TRUE;}
#define TRUE
Definition: types.h:120

Referenced by DriverEntry().

◆ MyAllocRelease()

VOID MyAllocRelease ( VOID  )

Referenced by DriverEntry().

◆ MyFreePool()

VOID __fastcall MyFreePool ( PCHAR  addr)

◆ MyReallocPool()

ULONG __fastcall MyReallocPool ( PCHAR  addr,
ULONG  OldLength,
PCHAR NewBuff,
ULONG  NewLength 
)

◆ MyReallocPool__()

ULONG MyReallocPool__ ( PCHAR  addr,
ULONG  len,
PCHAR pnewaddr,
ULONG  newlen 
)
inline

Definition at line 224 of file mem_tools.h.

224  {
225  ULONG _len, _newlen;
226  _newlen = MyAlignSize__(newlen);
227  _len = MyAlignSize__(len);
228  PCHAR newaddr;
229 
230  ASSERT(len && newlen);
231 
232 #ifdef MY_MEM_BOUNDS_CHECK
233  ULONG i;
234 
235  for(i=0; i<MY_HEAP_ALIGN+1; i++) {
236  if((UCHAR)(addr[len+i]) != (UCHAR)('A'+i)) {
237  __asm int 3;
238  break;
239  }
240  }
241 #endif //MY_MEM_BOUNDS_CHECK
242 
243  if ((_newlen != _len)
244 #ifdef MY_MEM_BOUNDS_CHECK
245  || TRUE
246 #endif //MY_MEM_BOUNDS_CHECK
247  ) {
248 #ifdef TRACK_SYS_ALLOC_CALLERS
249  newaddr = (PCHAR)DebugAllocatePool(NonPagedPool,_newlen, 0x202, __LINE__);
250 #else //TRACK_SYS_ALLOC_CALLERS
251  newaddr = (PCHAR)MyAllocatePool__(NonPagedPool,_newlen);
252 #endif //TRACK_SYS_ALLOC_CALLERS
253  if (!newaddr) {
254  __debugbreak();
255  *pnewaddr = addr;
256  return 0;
257  }
258 #ifdef MY_MEM_BOUNDS_CHECK
259  for(i=0; i<MY_HEAP_ALIGN+1; i++) {
260  newaddr[newlen+i] = (UCHAR)('A'+i);
261  }
262 #endif //MY_MEM_BOUNDS_CHECK
263  *pnewaddr = newaddr;
264  if(_newlen <= _len) {
265  RtlCopyMemory(newaddr, addr, newlen);
266  } else {
267  RtlCopyMemory(newaddr, addr, len);
268  RtlZeroMemory(newaddr+len, _newlen - len);
269  }
270 #ifdef MY_MEM_BOUNDS_CHECK
271  for(i=0; i<MY_HEAP_ALIGN+1; i++) {
272  if((UCHAR)(newaddr[newlen+i]) != (UCHAR)('A'+i)) {
273  __asm int 3;
274  break;
275  }
276  }
277 #endif //MY_MEM_BOUNDS_CHECK
278 
279  MyFreePool__(addr);
280  } else {
281  *pnewaddr = addr;
282  }
283  if(newlen > len) {
284  //RtlZeroMemory(newaddr+len, newlen - len);
285  }
286 /*
287 #ifdef MY_MEM_BOUNDS_CHECK
288  for(i=0; i<MY_HEAP_ALIGN+1; i++) {
289  newaddr[newlen+i] = (UCHAR)('A'+i);
290  }
291 #endif //MY_MEM_BOUNDS_CHECK
292 */
293  return newlen;
294 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
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
Definition: glfuncs.h:248
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
#define PCHAR
Definition: match.c:90
#define MyFreePool__(addr)
Definition: mem_tools.h:152
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
#define MyAlignSize__(size)
Definition: mem_tools.h:84
#define MY_HEAP_ALIGN
Definition: mem_tools.h:79
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by MyAppendUnicodeStringToString_(), MyAppendUnicodeToString_(), UDFBuildFreeSpaceBitmap(), UDFBuildTreeItemsList(), UDFCreateFile__(), UDFDirIndexGrow(), UDFDirIndexTrunc(), UDFFindFreeDloc(), UDFFindFreeFileId(), UDFInitializeVCB(), UDFLoadSparingTable(), UDFMergeMappings(), UDFOpenFile__(), UDFOpenRootFile__(), UDFPackDirectory__(), UDFResizeExtent(), and UDFVerifyFreeSpaceBitmap().

Variable Documentation

◆ BreakAddr

PCHAR BreakAddr

◆ MemTotalAllocated

ULONG MemTotalAllocated