Shouldn't code before breakfast:

* check against sizeof(void*)-1 instead of hardcoded 3.
* return B_NO_MEMORY instead of NULL if the allocation failed...
Thanks to Marcus and Ingo for proofreading :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21976 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-08-16 10:49:19 +00:00
parent dfd5242e7f
commit 491e46858b

View File

@ -278,14 +278,14 @@ memalign(size_t alignment, size_t size)
extern "C" int
posix_memalign(void **_pointer, size_t alignment, size_t size)
{
if ((alignment & 3) != 0 || _pointer == NULL)
if ((alignment & (sizeof(void *) - 1)) != 0 || _pointer == NULL)
return B_BAD_VALUE;
static processHeap *pHeap = getAllocator();
void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
size);
if (pointer == NULL)
return NULL;
return B_NO_MEMORY;
#if HEAP_LEAK_CHECK
add_address(pointer, size);