mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-07 11:58:41 +03:00
small optimizations, use bitwise aligne
This commit is contained in:
parent
7c26ce9280
commit
f0530b6a83
9 changed files with 59 additions and 32 deletions
7
src/os.c
7
src/os.c
|
@ -34,13 +34,6 @@ terms of the MIT license. A copy of the license can be found in the file
|
|||
----------------------------------------------------------- */
|
||||
bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* stats);
|
||||
|
||||
uintptr_t _mi_align_up(uintptr_t sz, size_t alignment) {
|
||||
uintptr_t x = (sz / alignment) * alignment;
|
||||
if (x < sz) x += alignment;
|
||||
if (x < sz) return 0; // overflow
|
||||
return x;
|
||||
}
|
||||
|
||||
static void* mi_align_up_ptr(void* p, size_t alignment) {
|
||||
return (void*)_mi_align_up((uintptr_t)p, alignment);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue