1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Consolidate valloc/pvalloc code.

To make malloc code more maintainable we make malloc and pvalloc share
logic with memalign.
This commit is contained in:
Ondřej Bílka
2013-11-20 15:46:02 +01:00
parent 4712799fbb
commit 10ad46bc65
4 changed files with 44 additions and 112 deletions

View File

@ -376,6 +376,13 @@ memalign_check(size_t alignment, size_t bytes, const void *caller)
return 0;
}
/* Make sure alignment is power of 2. */
if (!powerof2(alignment)) {
size_t a = MALLOC_ALIGNMENT * 2;
while (a < alignment) a <<= 1;
alignment = a;
}
(void)mutex_lock(&main_arena.mutex);
mem = (top_check() >= 0) ? _int_memalign(&main_arena, alignment, bytes+1) :
NULL;