File indexing completed on 2024-11-15 09:57:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TStorage
0013 #define ROOT_TStorage
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "Rtypes.h"
0026
0027 typedef void (*FreeHookFun_t)(void*, void *addr, size_t);
0028 typedef void *(*ReAllocFun_t)(void*, size_t);
0029 typedef void *(*ReAllocCFun_t)(void*, size_t, size_t);
0030 typedef char *(*ReAllocCharFun_t)(char*, size_t, size_t);
0031
0032
0033 class TStorage {
0034
0035 private:
0036 static size_t fgMaxBlockSize;
0037 static FreeHookFun_t fgFreeHook;
0038 static void *fgFreeHookData;
0039 static ReAllocCFun_t fgReAllocCHook;
0040 static Bool_t fgHasCustomNewDelete;
0041
0042
0043 enum {
0044 kIsOnHeap = 0x01000000,
0045 };
0046
0047 public:
0048 static const UInt_t kObjectAllocMemValue = 0x99999999;
0049
0050
0051 public:
0052 virtual ~TStorage() { }
0053
0054 static FreeHookFun_t GetFreeHook();
0055 static void *GetFreeHookData();
0056 static size_t GetMaxBlockSize();
0057 static void *Alloc(size_t size);
0058 static void Dealloc(void *ptr);
0059 static void *ReAlloc(void *vp, size_t size, size_t oldsize);
0060 static char *ReAllocChar(char *vp, size_t size, size_t oldsize);
0061 static Int_t *ReAllocInt(Int_t *vp, size_t size, size_t oldsize);
0062 static void *ObjectAlloc(size_t size);
0063 static void *ObjectAllocArray(size_t size);
0064 static void *ObjectAlloc(size_t size, void *vp);
0065 static void ObjectDealloc(void *vp);
0066 #ifdef R__SIZEDDELETE
0067 static void ObjectDealloc(void *vp, size_t size);
0068 #endif
0069 static void ObjectDealloc(void *vp, void *ptr);
0070
0071 static void EnterStat(size_t size, void *p);
0072 static void RemoveStat(void *p);
0073 static void PrintStatistics();
0074 static void SetMaxBlockSize(size_t size);
0075 static void SetFreeHook(FreeHookFun_t func, void *data);
0076 static void SetReAllocHooks(ReAllocFun_t func1, ReAllocCFun_t func2);
0077 static void SetCustomNewDelete();
0078 static void EnableStatistics(int size= -1, int ix= -1);
0079
0080 static Bool_t HasCustomNewDelete();
0081
0082 static Bool_t FilledByObjectAlloc(volatile const UInt_t* const member);
0083 static void UpdateIsOnHeap(volatile const UInt_t &uniqueID, volatile UInt_t &bits);
0084
0085 ClassDef(TStorage,0)
0086 };
0087
0088 inline Bool_t TStorage::FilledByObjectAlloc(volatile const UInt_t *const member) {
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 R__INTENTIONALLY_UNINIT_BEGIN
0111 return *member == kObjectAllocMemValue;
0112 R__INTENTIONALLY_UNINIT_END
0113 }
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123 R__NEVER_INLINE void TStorage::UpdateIsOnHeap(volatile const UInt_t &uniqueID, volatile UInt_t &bits) {
0124 if (TStorage::FilledByObjectAlloc(&uniqueID))
0125 bits = bits | kIsOnHeap;
0126 else
0127 bits = bits & ~kIsOnHeap;
0128 }
0129
0130
0131 inline size_t TStorage::GetMaxBlockSize() { return fgMaxBlockSize; }
0132
0133 inline void TStorage::SetMaxBlockSize(size_t size) { fgMaxBlockSize = size; }
0134
0135 inline FreeHookFun_t TStorage::GetFreeHook() { return fgFreeHook; }
0136
0137 namespace ROOT {
0138 namespace Internal {
0139 using FreeIfTMapFile_t = bool(void*);
0140 R__EXTERN FreeIfTMapFile_t *gFreeIfTMapFile;
0141 R__EXTERN void *gMmallocDesc;
0142 }
0143 }
0144
0145 #endif