MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Free

Method Free

Source/Memory/block_allocator.cpp:106–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void BlockAllocator::Free(void* ptr) {
107 // AssertMainThread();
108 for (size_t i = 0; i < block_count; i++) {
109 if (allocations[i].ptr == ptr) {
110 allocations_placements.FreeBits(allocations[i].block_index, allocations[i].block_count);
111 allocations[i] = BlockAllocation();
112 return;
113 }
114 }
115
116 vector<void*>::iterator backupit;
117 for (backupit = backup.begin(); backupit != backup.end(); backupit++) {
118 if (*backupit == ptr) {
119 OG_FREE(ptr);
120 backup.erase(backupit);
121 return;
122 }
123 }
124
125 if (!no_log) {
126 LOGF << "Could not find an allocation for " << ptr << " unable to free." << endl;
127 }
128}

Callers

nothing calls this directly

Calls 5

BlockAllocationClass · 0.85
FreeBitsMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected