42#if !defined(R__NOSTATS)
45# define MEM_CHECKOBJECTPOINTERS
48#if defined(MEM_STAT) && !defined(MEM_DEBUG)
54# define storage_size(p) ((size_t)(((size_t*)p)[-1]))
56# define storage_size(p) ((size_t)(((int*)p)[-2]))
59# define storage_size(p) ((size_t)0)
154 static const char *where =
"TStorage::Alloc";
157 void *vp = ::operator
new[](
size);
159 void *vp = ::operator
new(
size);
173 ::operator
delete[](ptr);
175 ::operator
delete(ptr);
185 ::Obsolete(
"ReAlloc(void*,size_t)",
"v5-34-00",
"v6-02-00");
186 ::Info(
"ReAlloc(void*,size_t)",
"please use ReAlloc(void*,size_t,size_t)");
196 static const char *where =
"TStorage::ReAlloc";
199 void *vp = ::operator
new[](
size);
201 void *vp = ::operator
new(
size);
211 memmove(vp, ovp,
size);
213 ::operator
delete[](ovp);
215 ::operator
delete(ovp);
234 static const char *where =
"TStorage::ReAlloc";
240 void *vp = ::operator
new[](
size);
242 void *vp = ::operator
new(
size);
252 if (
size > oldsize) {
253 memcpy(vp, ovp, oldsize);
254 memset((
char*)vp+oldsize, 0,
size-oldsize);
256 memcpy(vp, ovp,
size);
258 ::operator
delete[](ovp);
260 ::operator
delete(ovp);
271 static const char *where =
"TStorage::ReAllocChar";
274 if (ovp ==
nullptr) {
286 if (
size > oldsize) {
287 memcpy(vp, ovp, oldsize);
288 memset((
char*)vp+oldsize, 0,
size-oldsize);
290 memcpy(vp, ovp,
size);
301 static const char *where =
"TStorage::ReAllocInt";
304 if (ovp ==
nullptr) {
316 if (
size > oldsize) {
317 memcpy(vp, ovp, oldsize*
sizeof(
Int_t));
334 void* space = ::operator
new(sz);
346 void* space = ::operator
new(sz);
366 ::operator
delete(vp);
384 ::operator
delete(vp,
size);
415#if defined(MEM_DEBUG) && defined(MEM_STAT)
421 Printf(
"Heap statistics");
422 Printf(
"%12s%12s%12s%12s",
"size",
"alloc",
"free",
"diff");
423 Printf(
"================================================");
433 Printf(
"------------------------------------------------");
439 Printf(
"------------------------------------------------");
444 Printf(
"================================================");
461 int idum =
size;
int iidum = ix;
469 ::Obsolete(
"GetHeapBegin()",
"v5-34-00",
"v6-02-00");
478 ::Obsolete(
"GetHeapBegin()",
"v5-34-00",
"v6-02-00");
513 ::Obsolete(
"AddToHeap(ULong_t,ULong_t)",
"v5-34-00",
"v6-02-00");
521 ::Obsolete(
"IsOnHeap(void*)",
"v5-34-00",
"v6-02-00");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers)
Use this function to declare a function obsolete.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
static const char * gSpaceErr
static Int_t gTraceCapacity
static Bool_t gMemStatistics
static Int_t gFreed[kObjMaxSize]
static void ** gTraceArray
static Int_t gAllocated[kObjMaxSize]
static Int_t gAllocatedTotal
void *(* ReAllocCFun_t)(void *, size_t, size_t)
void *(* ReAllocFun_t)(void *, size_t)
void(* FreeHookFun_t)(void *, void *addr, size_t)
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
R__EXTERN TVirtualMutex * gGlobalMutex
#define R__LOCKGUARD(mutex)
static ReAllocCFun_t fgReAllocCHook
static void RemoveStat(void *p)
Register a memory free operation.
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
static Bool_t fgHasCustomNewDelete
static char * ReAllocChar(char *vp, size_t size, size_t oldsize)
Reallocate (i.e.
static FreeHookFun_t fgFreeHook
static Bool_t HasCustomNewDelete()
return the has custom delete flag
static void EnterStat(size_t size, void *p)
Register a memory allocation operation.
static ULong_t GetHeapBegin()
static void ObjectDealloc(void *vp)
Used to deallocate a TObject on the heap (via TObject::operator delete()).
static void SetFreeHook(FreeHookFun_t func, void *data)
Set a free handler.
static void SetCustomNewDelete()
set the has custom delete flag
static void AddToHeap(ULong_t begin, ULong_t end)
add a range to the heap
static ULong_t GetHeapEnd()
static void * GetFreeHookData()
return static free hook data
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
static void SetMaxBlockSize(size_t size)
static void * fgFreeHookData
static Bool_t IsOnHeap(void *p)
is object at p in the heap?
static const UInt_t kObjectAllocMemValue
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
static size_t fgMaxBlockSize
static Int_t * ReAllocInt(Int_t *vp, size_t size, size_t oldsize)
Reallocate (i.e.
static void SetReAllocHooks(ReAllocFun_t func1, ReAllocCFun_t func2)
Set a custom ReAlloc handlers.
static void * ObjectAllocArray(size_t size)
Used to allocate array of TObject on the heap (via TObject::operator new[]()).
static void EnableStatistics(int size=-1, int ix=-1)
Enable memory usage statistics gathering.
static ReAllocFun_t fgReAllocHook
static size_t GetMaxBlockSize()
static void * ObjectAlloc(size_t size)
Used to allocate a TObject on the heap (via TObject::operator new()).
static void PrintStatistics()
Print memory usage statistics.
R__EXTERN FreeIfTMapFile_t * gFreeIfTMapFile
R__EXTERN void * gMmallocDesc
bool(void *) FreeIfTMapFile_t
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.