mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
add is_in_heap_region function
This commit is contained in:
parent
8390c46503
commit
f646cc925d
2 changed files with 12 additions and 1 deletions
10
src/memory.c
10
src/memory.c
|
@ -104,6 +104,16 @@ static size_t mi_good_commit_size(size_t size) {
|
|||
return _mi_align_up(size, _mi_os_large_page_size());
|
||||
}
|
||||
|
||||
// Return if a pointer points into a region reserved by us.
|
||||
bool mi_is_in_heap_region(const void* p) {
|
||||
size_t count = mi_atomic_read(®ions_count);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
uint8_t* start = (uint8_t*)mi_atomic_read_ptr(®ions[i].start);
|
||||
if (start != NULL && (uint8_t*)p >= start && (uint8_t*)p < start + MI_REGION_SIZE) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
Commit from a region
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue