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:
@@ -278,14 +278,14 @@ memalign(size_t alignment, size_t size)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
posix_memalign(void **_pointer, size_t alignment, size_t size)
|
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;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
static processHeap *pHeap = getAllocator();
|
static processHeap *pHeap = getAllocator();
|
||||||
void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
|
void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment,
|
||||||
size);
|
size);
|
||||||
if (pointer == NULL)
|
if (pointer == NULL)
|
||||||
return NULL;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
#if HEAP_LEAK_CHECK
|
#if HEAP_LEAK_CHECK
|
||||||
add_address(pointer, size);
|
add_address(pointer, size);
|
||||||
|
|||||||
Reference in New Issue
Block a user