Add alignment support to chunk_alloc().

This commit is contained in:
Mike Hommey 2012-04-10 19:50:33 +02:00 committed by Jason Evans
parent c5851eaf6e
commit eae269036c
9 changed files with 87 additions and 138 deletions

View file

@ -27,19 +27,20 @@ size_t arena_maxclass; /* Max size class for arenas. */
* advantage of them if they are returned.
*/
void *
chunk_alloc(size_t size, bool base, bool *zero)
chunk_alloc(size_t size, size_t alignment, bool base, bool *zero)
{
void *ret;
assert(size != 0);
assert((size & chunksize_mask) == 0);
assert((alignment & chunksize_mask) == 0);
if (config_dss) {
ret = chunk_alloc_dss(size, zero);
ret = chunk_alloc_dss(size, alignment, zero);
if (ret != NULL)
goto RETURN;
}
ret = chunk_alloc_mmap(size);
ret = chunk_alloc_mmap(size, alignment);
if (ret != NULL) {
*zero = true;
goto RETURN;