mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 11:34:38 +03:00
add is_aligned check
This commit is contained in:
parent
d9f6ab58c5
commit
864e4be5ce
2 changed files with 9 additions and 1 deletions
|
@ -633,7 +633,9 @@ void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero)
|
|||
memset((uint8_t*)newp + start, 0, newsize - start);
|
||||
}
|
||||
if mi_likely(p != NULL) {
|
||||
_mi_memcpy_aligned(newp, p, (newsize > size ? size : newsize));
|
||||
if mi_likely(_mi_is_aligned(p, sizeof(uintptr_t))) { // a client may pass in an arbitrary pointer `p`..
|
||||
_mi_memcpy_aligned(newp, p, (newsize > size ? size : newsize));
|
||||
}
|
||||
mi_free(p); // only free the original pointer if successful
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue