malloc_debug: align allocations

* Align all allocations of more than 8 bytes to 8-byte.
* Avoids hitting ASSERTs in WebKit when built in debug mode (it assumes
at least 8 byte alignment)
This commit is contained in:
Adrien Destugues 2014-03-04 17:29:30 +01:00
parent 81abd9ed03
commit 217f090f9e
2 changed files with 5 additions and 5 deletions

View File

@ -966,7 +966,7 @@ memalign(size_t alignment, size_t size)
extern "C" void*
malloc(size_t size)
{
return memalign(0, size);
return memalign(size >= 8 ? 8 : 0, size);
}
@ -987,7 +987,7 @@ realloc(void* address, size_t newSize)
}
if (address == NULL)
return memalign(0, newSize);
return memalign(size >= 8 ? 8 : 0, newSize);
return guarded_heap_realloc(address, newSize);
}

View File

@ -1465,7 +1465,7 @@ heap_realloc(heap_allocator *heap, void *address, void **newAddress,
newSize -= sizeof(addr_t) + sizeof(heap_leak_check_info);
// if not, allocate a new chunk of memory
*newAddress = memalign(0, newSize);
*newAddress = memalign(newSize >= 8 ? 8 : 0, newSize);
if (*newAddress == NULL) {
// we tried but it didn't work out, but still the operation is done
return B_OK;
@ -1937,7 +1937,7 @@ malloc(size_t size)
if (sUseGuardPage)
return heap_debug_malloc_with_guard_page(size);
return memalign(0, size);
return memalign(size >= 8 ? 8 : 0, size);
}
@ -1978,7 +1978,7 @@ void *
realloc(void *address, size_t newSize)
{
if (address == NULL)
return memalign(0, newSize);
return memalign(newSize >= 8 ? 8 : 0, newSize);
if (newSize == 0) {
free(address);