mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-09 00:39:32 +03:00
fix NULL check in realloc
This commit is contained in:
parent
64394a6a43
commit
b1d3cde23f
2 changed files with 3 additions and 1 deletions
|
@ -709,6 +709,8 @@ static void* mi_heap_try_remap_zero(mi_heap_t* heap, mi_segment_t* segment, void
|
|||
|
||||
void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero) mi_attr_noexcept {
|
||||
// if p == NULL then behave as malloc.
|
||||
if mi_unlikely(p==NULL) return _mi_heap_malloc_zero(heap,newsize,zero);
|
||||
|
||||
// else if size == 0 then reallocate to a zero-sized block (and don't return NULL, just as mi_malloc(0)).
|
||||
// (this means that returning NULL always indicates an error, and `p` will not have been freed in that case.)
|
||||
const size_t size = _mi_usable_size(p,"mi_realloc"); // also works if p == NULL (with size 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue