MCPcopy Create free account
hub / github.com/beefytech/Beef / Clear

Method Clear

BeefySysLib/util/Heap.cpp:135–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133//#define BFCE_DEBUG_HEAP
134
135void ContiguousHeap::Clear(int maxAllocSize)
136{
137#ifdef BFCE_DEBUG_HEAP
138 OutputDebugStrF("ContiguousHeap::Clear\n");
139#endif
140
141 if (mBlockDataOfs == 0)
142 return;
143
144 if ((mMemorySize != -1) && (mMemorySize > maxAllocSize))
145 {
146 free(mMetadata);
147 mMetadata = NULL;
148 mMemorySize = 0;
149 mBlockDataOfs = 0;
150 mFreeList.Clear();
151 return;
152 }
153
154 for (auto idx : mFreeList)
155 {
156 auto block = CH_REL_TO_ABS(idx);
157 block->mKind = (ChBlockKind)0;
158 }
159
160 auto blockList = (ChList*)mMetadata;
161 if (blockList->mHead != -1)
162 {
163 auto block = CH_REL_TO_ABS(blockList->mHead);
164 while (block != NULL)
165 {
166 block->mKind = (ChBlockKind)0;
167 if (block->mNext == -1)
168 break;
169 block = CH_REL_TO_ABS(block->mNext);
170 }
171 }
172
173 blockList->mHead = -1;
174 blockList->mTail = -1;
175 mBlockDataOfs = 0;
176 mFreeList.Clear();
177
178 Validate();
179}
180
181static int gAllocCount = 0;
182

Callers 8

DestroyMethod · 0.45
GetClipboardDataMethod · 0.45
FrameEndMethod · 0.45
BfpFile_GetActualPathFunction · 0.45
WorkerProcMethod · 0.45
ShutdownMethod · 0.45

Calls 1

freeFunction · 0.50

Tested by

no test coverage detected