NewDelete.cxx File Reference

#include <stdlib.h>
#include <errno.h>
#include "MemCheck.h"
#include "TObjectTable.h"
#include "TError.h"
#include "TMapFile.h"
#include "TSystem.h"
#include "mmalloc.h"

Go to the source code of this file.

Classes

class  TReAllocInit

Defines

#define MEM_DEBUG
#define MEM_STAT
#define MEM_CHECKOBJECTPOINTERS
#define MEM_MAGIC   ((unsigned char)0xAB)
#define storage_size(p)   ((size_t)(((int*)p)[-2]))
#define RealStart(p)   ((char*)(p) - 2*sizeof(int))
#define StoreSize(p, sz)   (*((int*)(p)) = (sz))
#define ExtStart(p)   ((char*)(p) + 2*sizeof(int))
#define RealSize(sz)   ((sz) + 2*sizeof(int) + sizeof(char))
#define StoreMagic(p, sz)   *((unsigned char*)(p)+sz+2*sizeof(int)) = MEM_MAGIC
#define MemClear(p, start, len)   if ((len) > 0) memset(&((char*)(p))[(start)], 0, (len))
#define TestMagic(p, sz)   (*((unsigned char*)(p)+sz) != MEM_MAGIC)
#define CheckMagic(p, s, where)
#define CheckFreeSize(p, where)
#define RemoveStatMagic(p, where)
#define StoreSizeMagic(p, size, where)
#define MemClearRe(p, start, len)   if ((len) > 0) memset(&((char*)(p))[(start)], 0, (len))
#define CallFreeHook(p, size)   if (TStorage::GetFreeHook()) TStorage::GetFreeHook()(TStorage::GetFreeHookData(), (p), (size))
#define CheckObjPtr(p, name)
#define EnterStat(s, p)   TStorage::EnterStat(s, p)
#define RemoveStat(p)   TStorage::RemoveStat(p)
#define R__THROW_BAD
#define R__THROW_NULL

Functions

void * CustomReAlloc1 (void *ovp, size_t size)
void * CustomReAlloc2 (void *ovp, size_t size, size_t oldsize)
void * operator new (size_t size) R__THROW_BAD
void * operator new (size_t size, void *vp) R__THROW_NULL
void operator delete (void *ptr) R__THROW_NULL

Variables

static TReAllocInit gReallocInit
static const char * gSpaceErr = "storage exhausted (failed to allocate %ld bytes)"
static int gNewInit = 0


Define Documentation

#define CallFreeHook ( p,
size   )     if (TStorage::GetFreeHook()) TStorage::GetFreeHook()(TStorage::GetFreeHookData(), (p), (size))

Definition at line 143 of file NewDelete.cxx.

Referenced by operator delete().

#define CheckFreeSize ( p,
where   ) 

Value:

if (storage_size((p)) > TStorage::GetMaxBlockSize()) \
         Fatal(where, "unreasonable size (%ld)", (Long_t)storage_size(p));

Definition at line 115 of file NewDelete.cxx.

#define CheckMagic ( p,
s,
where   ) 

Value:

if (TestMagic(p, s))    \
         Fatal(where, "%s", "storage area overwritten");

Definition at line 112 of file NewDelete.cxx.

#define CheckObjPtr ( p,
name   ) 

Definition at line 148 of file NewDelete.cxx.

Referenced by operator delete().

#define EnterStat ( s,
p   )     TStorage::EnterStat(s, p)

Definition at line 156 of file NewDelete.cxx.

#define ExtStart ( p   )     ((char*)(p) + 2*sizeof(int))

Definition at line 105 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), CustomReAlloc2(), and operator new().

#define MEM_CHECKOBJECTPOINTERS

Definition at line 85 of file NewDelete.cxx.

#define MEM_DEBUG

Definition at line 83 of file NewDelete.cxx.

#define MEM_MAGIC   ((unsigned char)0xAB)

Definition at line 93 of file NewDelete.cxx.

#define MEM_STAT

Definition at line 84 of file NewDelete.cxx.

#define MemClear ( p,
start,
len   )     if ((len) > 0) memset(&((char*)(p))[(start)], 0, (len))

Definition at line 109 of file NewDelete.cxx.

Referenced by operator delete().

#define MemClearRe ( p,
start,
len   )     if ((len) > 0) memset(&((char*)(p))[(start)], 0, (len))

Definition at line 140 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), and CustomReAlloc2().

#define R__THROW_BAD

Definition at line 185 of file NewDelete.cxx.

#define R__THROW_NULL

Definition at line 186 of file NewDelete.cxx.

#define RealSize ( sz   )     ((sz) + 2*sizeof(int) + sizeof(char))

Definition at line 106 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), CustomReAlloc2(), operator delete(), and operator new().

#define RealStart ( p   )     ((char*)(p) - 2*sizeof(int))

Definition at line 103 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), CustomReAlloc2(), and operator delete().

#define RemoveStat ( p   )     TStorage::RemoveStat(p)

Definition at line 158 of file NewDelete.cxx.

#define RemoveStatMagic ( p,
where   ) 

Value:

CheckFreeSize(p, where); \
      RemoveStat(p); \
      CheckMagic(p, storage_size(p), where)

Definition at line 118 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), CustomReAlloc2(), and operator delete().

#define storage_size ( p   )     ((size_t)(((int*)p)[-2]))

Definition at line 102 of file NewDelete.cxx.

#define StoreMagic ( p,
sz   )     *((unsigned char*)(p)+sz+2*sizeof(int)) = MEM_MAGIC

Definition at line 107 of file NewDelete.cxx.

#define StoreSize ( p,
sz   )     (*((int*)(p)) = (sz))

Definition at line 104 of file NewDelete.cxx.

#define StoreSizeMagic ( p,
size,
where   ) 

Value:

Definition at line 122 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), CustomReAlloc2(), and operator new().

#define TestMagic ( p,
sz   )     (*((unsigned char*)(p)+sz) != MEM_MAGIC)

Definition at line 111 of file NewDelete.cxx.


Function Documentation

void * CustomReAlloc1 ( void *  ovp,
size_t  size 
)

Definition at line 314 of file NewDelete.cxx.

References TMemHashTable::AddPointer(), ExtStart, Fatal(), gMmallocDesc, gNewInit, gSpaceErr, TROOT::MemCheck(), MemClearRe, mrealloc(), operator new(), realloc(), RealSize, RealStart, RemoveStatMagic, size_t, storage_size, StoreSizeMagic, and vp.

Referenced by TReAllocInit::TReAllocInit().

void * CustomReAlloc2 ( void *  ovp,
size_t  size,
size_t  oldsize 
)

Definition at line 349 of file NewDelete.cxx.

References TMemHashTable::AddPointer(), ExtStart, Fatal(), fprintf(), gMmallocDesc, gNewInit, gSpaceErr, TROOT::MemCheck(), MemClearRe, mrealloc(), operator new(), realloc(), RealSize, RealStart, RemoveStatMagic, storage_size, StoreSizeMagic, and vp.

Referenced by TReAllocInit::TReAllocInit().

void operator delete ( void *  ptr  ) 

Definition at line 252 of file NewDelete.cxx.

References CallFreeHook, CheckObjPtr, Fatal(), free(), TMemHashTable::FreePointer(), TSystem::GetErrno(), TMapFile::GetMmallocDesc(), gNewInit, TMapFile::IsWritable(), TROOT::MemCheck(), MemClear, mfree(), ptr, RealSize, RealStart, RemoveStatMagic, TSystem::ResetErrno(), storage_size, SysError(), and TMapFile::WhichMapFile().

void* operator new ( size_t  size,
void *  vp 
)

Definition at line 221 of file NewDelete.cxx.

References TMemHashTable::AddPointer(), calloc(), ExtStart, Fatal(), gMmallocDesc, gNewInit, gSpaceErr, mcalloc(), TROOT::MemCheck(), RealSize, TStorage::SetCustomNewDelete(), size, StoreSizeMagic, and vp.

void* operator new ( size_t  size  ) 

Definition at line 193 of file NewDelete.cxx.

References TMemHashTable::AddPointer(), calloc(), ExtStart, Fatal(), gMmallocDesc, gNewInit, gSpaceErr, mcalloc(), TROOT::MemCheck(), RealSize, TStorage::SetCustomNewDelete(), size, StoreSizeMagic, and vp.


Variable Documentation

int gNewInit = 0 [static]

Definition at line 190 of file NewDelete.cxx.

Referenced by CustomReAlloc1(), CustomReAlloc2(), operator delete(), and operator new().

TReAllocInit gReallocInit [static]

Definition at line 77 of file NewDelete.cxx.

const char* gSpaceErr = "storage exhausted (failed to allocate %ld bytes)" [static]

Definition at line 189 of file NewDelete.cxx.

Referenced by TStorage::Alloc(), CustomReAlloc1(), CustomReAlloc2(), operator new(), TStorage::ReAlloc(), TStorage::ReAllocChar(), and TStorage::ReAllocInt().


Generated on Tue Jul 5 15:57:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1