mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-01 17:24:38 +03:00
return NULL in mi_arena_try_alloc_at if we cannot commit but commit was requested
This commit is contained in:
parent
bea8a12d3d
commit
25fdd50666
1 changed files with 12 additions and 11 deletions
23
src/arena.c
23
src/arena.c
|
@ -216,20 +216,21 @@ static mi_decl_noinline void* mi_arena_try_alloc_at(
|
||||||
// now actually commit
|
// now actually commit
|
||||||
bool commit_zero = false;
|
bool commit_zero = false;
|
||||||
if (!_mi_os_commit_ex(p, mi_size_of_slices(slice_count), &commit_zero, mi_size_of_slices(slice_count - already_committed_count))) {
|
if (!_mi_os_commit_ex(p, mi_size_of_slices(slice_count), &commit_zero, mi_size_of_slices(slice_count - already_committed_count))) {
|
||||||
memid->initially_committed = false;
|
// if the commit fails, roll back and return NULL
|
||||||
|
_mi_arenas_free(p, mi_size_of_slices(slice_count), *memid); // this will decommit as well (if partially committed)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// committed
|
// committed
|
||||||
if (commit_zero) { memid->initially_zero = true; }
|
if (commit_zero) { memid->initially_zero = true; }
|
||||||
#if MI_DEBUG > 1
|
#if MI_DEBUG > 1
|
||||||
if (memid->initially_zero) {
|
if (memid->initially_zero) {
|
||||||
if (!mi_mem_is_zero(p, mi_size_of_slices(slice_count))) {
|
if (!mi_mem_is_zero(p, mi_size_of_slices(slice_count))) {
|
||||||
_mi_error_message(EFAULT, "interal error: arena allocation was not zero-initialized!\n");
|
_mi_error_message(EFAULT, "interal error: arena allocation was not zero-initialized!\n");
|
||||||
memid->initially_zero = false;
|
memid->initially_zero = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// already fully commited.
|
// already fully commited.
|
||||||
|
|
Loading…
Add table
Reference in a new issue