MCPcopy Create free account
hub / github.com/anjo76/angelscript / MyFreeWithStats

Function MyFreeWithStats

sdk/tests/test_feature/source/utils.cpp:157–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void MyFreeWithStats(void *address)
158{
159#if !defined(__psp2__) && !defined(__CELLOS_LV2__)
160 // Count the number of deallocations made
161 numFrees++;
162
163 // Remove the memory block from the list of allocated blocks
164 size_t allocSize = 0;
165 map<void*,size_t>::iterator i = memSize.find(address);
166 if( i != memSize.end() )
167 {
168 // Decrease the current amount of allocated memory
169 allocSize = i->second;
170 currentMemAlloc -= allocSize;
171 memSize.erase(i);
172 }
173 else
174 assert(false);
175
176 // Verify which memory we are currently removing so we know we did the allocation, and where it was allocated
177 map<void*,int>::iterator i2 = memCount.find(address);
178 if( i2 != memCount.end() )
179 {
180// int numAlloc = i2->second;
181 memCount.erase(i2);
182 }
183 else
184 assert(false);
185
186#ifdef TRACK_LOCATIONS
187 // Find out where the allocation was from
188 map<void*, loc>::iterator it = memAllocedFrom.find(address);
189 if (it != memAllocedFrom.end())
190 {
191 map<loc, counters>::iterator i2 = locCount.find(it->second);
192 if (i2 != locCount.end())
193 {
194 i2->second.frees++;
195 i2->second.totalMemFreed += allocSize;
196 }
197
198 memAllocedFrom.erase(it);
199 }
200 else
201 assert(false);
202#endif
203#endif
204 // Free the actual memory
205 free(address);
206}
207
208void InstallMemoryManager()
209{

Callers

nothing calls this directly

Calls 2

findMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected