#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 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.
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 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().
Definition at line 103 of file NewDelete.cxx.
Referenced by CustomReAlloc1(), CustomReAlloc2(), and operator delete().
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().
Definition at line 102 of file NewDelete.cxx.
Definition at line 107 of file NewDelete.cxx.
Definition at line 104 of file NewDelete.cxx.
Value:
StoreSize(p, size); \ StoreMagic(p, size); \ EnterStat(size, ExtStart(p)); \ CheckObjPtr(ExtStart(p), where);
Definition at line 122 of file NewDelete.cxx.
Referenced by CustomReAlloc1(), CustomReAlloc2(), and operator new().
Definition at line 111 of file NewDelete.cxx.
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().
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.
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().