MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / free

Method free

source/util/bnativeheap.cpp:159–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void BNativeHeap::free(void* address) {
160 if (!address) {
161 return;
162 }
163 U32 index = *(((U32*)address) - 1);
164 if (index >= BNATIVEHEAD_64K_BLOCK_SIZE) {
165 U8* rawAddress = ((U8*)address) - 4;
166 if (delayedFree) {
167 delayedFreeLargeBlocks.set(rawAddress, KSystem::getMilliesSinceStart());
168 } else {
169 Platform::releaseNativeMemory(rawAddress, index);
170 }
171 largeBlocks.remove(rawAddress);
172 return;
173 }
174 if (delayedFree) {
175 U32* pTime = (U32*)address;
176 pTime--;
177 if (isCodeMemory) {
178 Platform::writeCodeToMemory(pTime, 4, [pTime]() {
179 *pTime = KSystem::getMilliesSinceStart();
180 });
181 } else {
182 *pTime = KSystem::getMilliesSinceStart();
183 }
184 }
185 buckets[index].push_front(address);
186}

Callers

nothing calls this directly

Calls 3

push_frontMethod · 0.80
setMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected