mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
minor edits
This commit is contained in:
parent
48ff5c178e
commit
16e9f30d56
1 changed files with 6 additions and 6 deletions
12
src/alloc.c
12
src/alloc.c
|
@ -811,12 +811,12 @@ mi_decl_nodiscard void* mi_zalloc_remappable(size_t size) mi_attr_noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
mi_decl_nodiscard void* mi_remap(void* p, size_t newsize) mi_attr_noexcept {
|
mi_decl_nodiscard void* mi_remap(void* p, size_t newsize) mi_attr_noexcept {
|
||||||
if (p == NULL) return mi_malloc(newsize);
|
if (p == NULL) return mi_malloc_remappable(newsize);
|
||||||
|
|
||||||
mi_segment_t* segment = mi_checked_ptr_segment(p, "mi_remap");
|
mi_segment_t* segment = mi_checked_ptr_segment(p, "mi_remap");
|
||||||
const mi_threadid_t tid = _mi_prim_thread_id();
|
const mi_threadid_t tid = _mi_prim_thread_id();
|
||||||
if (segment->thread_id != tid) {
|
if (segment->thread_id != tid) {
|
||||||
_mi_warning_message("cannot remap memory from a different thread (address %p, newsize %zu bytes)\n", p, newsize);
|
_mi_warning_message("cannot remap memory from a different thread (address: %p, newsize: %zu bytes)\n", p, newsize);
|
||||||
return mi_realloc(p, newsize);
|
return mi_realloc(p, newsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,8 +831,8 @@ mi_decl_nodiscard void* mi_remap(void* p, size_t newsize) mi_attr_noexcept {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remappable memory?
|
||||||
if (segment->memid.memkind == MI_MEM_OS_REMAP) {
|
if (segment->memid.memkind == MI_MEM_OS_REMAP) {
|
||||||
// we can remap
|
|
||||||
mi_heap_t* heap = mi_prim_get_default_heap();
|
mi_heap_t* heap = mi_prim_get_default_heap();
|
||||||
mi_assert_internal((void*)block == p);
|
mi_assert_internal((void*)block == p);
|
||||||
mi_assert_internal(heap->thread_id == tid);
|
mi_assert_internal(heap->thread_id == tid);
|
||||||
|
@ -847,14 +847,14 @@ mi_decl_nodiscard void* mi_remap(void* p, size_t newsize) mi_attr_noexcept {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_mi_verbose_message("unable to remap memory, huge remap (address: %p from %zu bytes to %zu bytes)\n", p, mi_usable_size(p), newsize);
|
_mi_verbose_message("unable to remap memory, huge remap (address: %p, from %zu bytes to %zu bytes)\n", p, mi_usable_size(p), newsize);
|
||||||
_mi_heap_huge_page_attach(heap, page);
|
_mi_heap_huge_page_attach(heap, page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_mi_verbose_message("unable to remap memory, not remappable (address: %p from %zu bytes to %zu bytes)\n", p, mi_usable_size(p), newsize);
|
_mi_verbose_message("unable to remap memory, not remappable (address: %p, from %zu bytes to %zu bytes)\n", p, mi_usable_size(p), newsize);
|
||||||
}
|
}
|
||||||
_mi_warning_message("unable to remap memory, fall back to reallocation (address: %p from %zu bytes to %zu bytes)\n", p, mi_usable_size(p), newsize);
|
_mi_warning_message("unable to remap memory, fall back to reallocation (address: %p, from %zu bytes to %zu bytes)\n", p, mi_usable_size(p), newsize);
|
||||||
return mi_realloc(p, newsize);
|
return mi_realloc(p, newsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue