summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-10-29 17:07:06 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-10-29 17:08:22 (GMT)
commit9e01ced1d14467c06d7e1db57982556c9e861372 (patch)
tree0bd3d18a95305fc2b8016f9c5079f9cdb6bd548c /src/corelib/global
parent2f5a5804fb42a4c956f366d002a94076d6623a45 (diff)
downloadQt-9e01ced1d14467c06d7e1db57982556c9e861372.zip
Qt-9e01ced1d14467c06d7e1db57982556c9e861372.tar.gz
Qt-9e01ced1d14467c06d7e1db57982556c9e861372.tar.bz2
Remove the posix_memalign and Win32 _aligned_malloc
MinGW doesn't have _aligned_malloc and posix_memalign doesn't have a realloc function. So use our own implementation in all platforms. Removing posix_memalign was reviewed by Brad, but I apparently lost the commit. Reviewed-by: Trust Me
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qmalloc.cpp38
1 files changed, 0 insertions, 38 deletions
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index 3584c50..4aab1bd 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -43,10 +43,6 @@
#include <stdlib.h>
-#ifdef Q_OS_WIN
-# include <malloc.h>
-#endif
-
/*
Define the container allocation functions in a separate file, so that our
users can easily override them.
@@ -71,38 +67,11 @@ void *qRealloc(void *ptr, size_t size)
void *qMallocAligned(size_t size, size_t alignment)
{
-#if defined(Q_OS_WIN)
- return _aligned_malloc(size, alignment);
-#elif defined(HAVE_POSIX_MEMALIGN)
- if (alignment <= sizeof(void*))
- return qMalloc(size);
-
- // we have posix_memalign
- void *ptr = 0;
- if (posix_memalign(&ptr, alignment, size) == 0)
- return ptr;
- return 0;
-#else
return qReallocAligned(0, size, 0, alignment);
-#endif
}
void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment)
{
-#if defined(Q_OS_WIN)
- Q_UNUSED(oldsize);
- return _aligned_realloc(oldptr, newsize, alignment);
-#elif defined(HAVE_POSIX_MEMALIGN)
- if (alignment <= sizeof(void*))
- return qRealloc(oldptr, newsize);
-
- void *newptr = qMallocAligned(newsize, alignment);
- if (!newptr)
- return 0;
- qMemCopy(newptr, oldptr, qMin(oldsize, newsize));
- qFree(oldptr);
- return newptr;
-#else
// fake an aligned allocation
Q_UNUSED(oldsize);
@@ -144,21 +113,14 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
faked.pptr[-1] = real.ptr;
return faked.ptr;
-#endif
}
void qFreeAligned(void *ptr)
{
-#if defined(Q_OS_WIN)
- _aligned_free(ptr);
-#elif defined(HAVE_POSIX_MEMALIGN)
- ::free(ptr);
-#else
if (!ptr)
return;
void **ptr2 = static_cast<void **>(ptr);
free(ptr2[-1]);
-#endif
}
QT_END_NAMESPACE