Revert hrev43455 and instead just align the size.

While this isn't really correct, it works for the use case it is
intended and doesn't open the can of worms we get when trying to do
memalign() across platforms (due to build tools use of KMessage).
This commit is contained in:
Michael Lotz
2011-12-10 21:03:14 +01:00
parent 33f0ed7a03
commit 5585262bb1
+3 -6
View File
@@ -6,8 +6,6 @@
#include <util/KMessage.h> #include <util/KMessage.h>
#include <malloc.h>
// for memalign()
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -610,8 +608,7 @@ KMessage::ReceiveFrom(port_id fromPort, bigtime_t timeout,
return error; return error;
// allocate a buffer // allocate a buffer
uint8* buffer = (uint8*)memalign(kMessageBufferAlignment, uint8* buffer = (uint8*)malloc(_Align(messageInfo->size));
messageInfo->size);
if (!buffer) if (!buffer)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -830,7 +827,7 @@ KMessage::_InitFromBuffer(bool sizeFromBuffer)
fBufferCapacity = size; fBufferCapacity = size;
} }
void* buffer = memalign(kMessageBufferAlignment, fBufferCapacity); void* buffer = malloc(_Align(fBufferCapacity));
if (buffer == NULL) if (buffer == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -964,7 +961,7 @@ KMessage::_AllocateSpace(int32 size, bool alignAddress, bool alignSize,
// reallocate if necessary // reallocate if necessary
if (fBuffer == &fHeader) { if (fBuffer == &fHeader) {
int32 newCapacity = _CapacityFor(newSize); int32 newCapacity = _CapacityFor(newSize);
void* newBuffer = memalign(kMessageBufferAlignment, newCapacity); void* newBuffer = malloc(_Align(newCapacity));
if (!newBuffer) if (!newBuffer)
return B_NO_MEMORY; return B_NO_MEMORY;
fBuffer = newBuffer; fBuffer = newBuffer;