ReactOS  0.4.15-dev-1386-g5cb9f87
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 310 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
#define NULL
Definition: types.h:112

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 230 of file mem_tools.h.

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

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