10#ifndef ROOT_Minuit2_StackAllocator
11#define ROOT_Minuit2_StackAllocator
20#ifdef MN_USE_STACK_ALLOC
21#define _MN_NO_THREAD_SAVE_
60#ifdef _MN_NO_THREAD_SAVE_
69#ifdef _MN_NO_THREAD_SAVE_
76#ifdef _MN_NO_THREAD_SAVE_
97 void* result =
malloc(nBytes);
98 if (!result)
throw std::bad_alloc();
105#ifdef _MN_NO_THREAD_SAVE_
107 int delBlock =
ToInt(p);
108 int nextBlock =
ReadInt( delBlock);
109 int previousBlock =
ReadInt( nextBlock -
sizeof(
int));
116 int nextNextBlock =
ReadInt(nextBlock);
117 WriteInt( nextNextBlock -
sizeof(
int), previousBlock);
119 WriteInt( previousBlock, nextNextBlock);
123#ifdef DEBUG_ALLOCATOR
134 int* ip = (
int*)(
fStack+offset);
145 int* ip =
reinterpret_cast<int*
>(
fStack+offset);
150 unsigned char*
pc =
static_cast<unsigned char*
>(p);
155 return userBlock -
sizeof(int);
159 const int fAlignment = 4;
160 int needed = nBytes % fAlignment == 0 ? nBytes : (nBytes/fAlignment+1)*fAlignment;
161 return needed + 2*
sizeof(int);
185 int beg2 =
ReadInt( end -
sizeof(
int));
226 return gStackAllocator;
static StackAllocator & Get()
StackAllocator controls the memory allocation/deallocation of Minuit.
void WriteInt(int offset, int Value)
void * Allocate(size_t nBytes)
void CheckOverflow(int n)
int AlignedSize(int nBytes)
define stack allocator symbol
static constexpr double pc