Fix compilation on posix-compliant systems.
authorErik Verbruggen <erik.verbruggen@digia.com>
Mon, 10 Dec 2012 08:56:30 +0000 (09:56 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 10 Dec 2012 09:12:57 +0000 (10:12 +0100)
memalign is deprecated and linux-only, and malloc.h does not exist on
non-glibc systems.

Change-Id: I44942378b7514c2a3fb6cb5f60256bbcc8ffe370
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qv4mm.cpp

index 60c6180..fe72551 100644 (file)
--- a/qv4mm.cpp
+++ b/qv4mm.cpp
@@ -37,7 +37,7 @@
 #include <QLinkedList>
 
 #include <iostream>
-#include <malloc.h>
+#include <cstdlib>
 
 using namespace QQmlJS::VM;
 
@@ -127,7 +127,8 @@ MemoryManager::MMObject *MemoryManager::alloc(std::size_t size)
             return alloc(size - sizeof(MMInfo));
 
     std::size_t allocSize = std::max(size, CHUNK_SIZE);
-    char *ptr = (char*)memalign(16, allocSize);
+    char *ptr = 0;
+    posix_memalign(reinterpret_cast<void**>(&ptr), 16, allocSize);
     m_d->heapChunks.append(qMakePair(ptr, allocSize));
 //    qDebug("Allocated new chunk of %lu bytes @ %p", allocSize, ptr);