MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_check_is_double_free

Function mi_check_is_double_free

3rd/mimalloc-2.0.9/src/alloc.c:204–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202#define mi_track_page(page,access) { size_t psize; void* pstart = _mi_page_start(_mi_page_segment(page),page,&psize); mi_track_mem_##access( pstart, psize); }
203
204static inline bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block) {
205 bool is_double_free = false;
206 mi_block_t* n = mi_block_nextx(page, block, page->keys); // pretend it is freed, and get the decoded first field
207 if (((uintptr_t)n & (MI_INTPTR_SIZE-1))==0 && // quick check: aligned pointer?
208 (n==NULL || mi_is_in_same_page(block, n))) // quick check: in same page or NULL?
209 {
210 // Suspicous: decoded value a in block is in the same page (or NULL) -- maybe a double free?
211 // (continue in separate function to improve code generation)
212 is_double_free = mi_check_is_double_freex(page, block);
213 }
214 return is_double_free;
215}
216#else
217static inline bool mi_check_is_double_free(const mi_page_t* page, const mi_block_t* block) {
218 MI_UNUSED(page);

Callers

nothing calls this directly

Calls 3

mi_block_nextxFunction · 0.85
mi_is_in_same_pageFunction · 0.85
mi_check_is_double_freexFunction · 0.85

Tested by

no test coverage detected