OSDN Git Service

remove qFree/qMalloc/etc.
authorIvailo Monev <xakepa10@laimg.moc>
Tue, 18 Oct 2016 20:06:38 +0000 (20:06 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Tue, 18 Oct 2016 20:06:38 +0000 (20:06 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/global/qglobal.h.cmake
src/core/kernel/qcore_unix_p.h
src/core/tools/qbytedata_p.h
src/core/tools/qcontiguouscache.cpp
src/core/tools/qcontiguouscache.h
src/declarative/qml/qmetaobjectbuilder.cpp

index df54b7d..3bb471c 100644 (file)
@@ -44,8 +44,6 @@
 
 #include <qconfig.h>
 #include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
 
 #define QT_VERSION_STR   "${KATIE_VERSION}"
 /*
@@ -1618,22 +1616,6 @@ Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
 Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
 
 /*
-   These functions are for compatibility only
-*/
-Q_CORE_EXPORT_INLINE void *qMalloc(size_t size) { return ::malloc(size); }
-Q_CORE_EXPORT_INLINE void qFree(void *ptr) { ::free(ptr); }
-Q_CORE_EXPORT_INLINE void *qRealloc(void *ptr, size_t size) { return ::realloc(ptr, size); }
-Q_CORE_EXPORT_INLINE void *qMemCopy(void *dest, const void *src, size_t n) { return ::memcpy(dest, src, n); }
-Q_CORE_EXPORT_INLINE void *qMemSet(void *dest, int c, size_t n) { return ::memset(dest, c, n); }
-Q_CORE_EXPORT_INLINE void *qMallocAligned(size_t size, size_t alignment) { Q_UNUSED(alignment); return qMalloc(size); }
-Q_CORE_EXPORT_INLINE void qFreeAligned(void *ptr) { qFree(ptr); }
-Q_CORE_EXPORT_INLINE void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment)
-{
-    Q_UNUSED(oldsize);
-    Q_UNUSED(alignment);
-    return qRealloc(ptr, size);
-}
-/*
    These functions make it possible to use standard C++ functions with
    a similar name from Qt header files (especially template classes).
 */
index 4493a0e..27d2c95 100644 (file)
 #include "qplatformdefs.h"
 #include "qatomic.h"
 
-#ifndef Q_OS_UNIX
-# error "qcore_unix_p.h included on a non-Unix system"
-#endif
-
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
 
-#if defined(Q_OS_VXWORKS)
-#  include <ioLib.h>
-#endif
-
 struct sockaddr;
 
 #if defined(Q_OS_LINUX) && defined(O_CLOEXEC)
index 8f99f84..b18121f 100644 (file)
@@ -102,7 +102,7 @@ public:
         bufferCompleteSize += bd.size();
     }
 
-    // return the first QByteData. User of this function has to qFree() its .data!
+    // return the first QByteData. User of this function has to free() its .data!
     // preferably use this function to read data.
     inline QByteArray read()
     {
@@ -110,14 +110,14 @@ public:
         return buffers.takeFirst();
     }
 
-    // return everything. User of this function has to qFree() its .data!
+    // return everything. User of this function has to free() its .data!
     // avoid to use this, it might malloc and memcpy.
     inline QByteArray readAll()
     {
         return read(bufferCompleteSize);
     }
 
-    // return amount. User of this function has to qFree() its .data!
+    // return amount. User of this function has to free() its .data!
     // avoid to use this, it might malloc and memcpy.
     inline QByteArray read(qint64 amount)
     {
@@ -128,7 +128,7 @@ public:
         return byteData;
     }
 
-    // return amount bytes. User of this function has to qFree() its .data!
+    // return amount bytes. User of this function has to free() its .data!
     // avoid to use this, it will memcpy.
     qint64 read(char* dst, qint64 amount)
     {
index 14e67bf..d582d15 100644 (file)
@@ -56,16 +56,6 @@ void QContiguousCacheData::dump() const
 }
 #endif
 
-QContiguousCacheData *QContiguousCacheData::allocate(int size, int alignment)
-{
-    return static_cast<QContiguousCacheData *>(qMallocAligned(size, alignment));
-}
-
-void QContiguousCacheData::freeData(QContiguousCacheData *data)
-{
-    qFreeAligned(data);
-}
-
 /*! \class QContiguousCache
     \brief The QContiguousCache class is a template class that provides a contiguous cache.
     \ingroup tools
index 6c87853..01174c6 100644 (file)
@@ -62,14 +62,6 @@ struct Q_CORE_EXPORT QContiguousCacheData
     int offset;
     uint sharable : 1;
 
-    // total is 24 bytes (HP-UX aCC: 40 bytes)
-    // the next entry is already aligned to 8 bytes
-    // there will be an 8 byte gap here if T requires 16-byte alignment
-    //  (such as long double on 64-bit platforms, __int128, __float128)
-
-    static QContiguousCacheData *allocate(int size, int alignment);
-    static void freeData(QContiguousCacheData *data);
-
 #ifdef QT_QCONTIGUOUSCACHE_DEBUG
     void dump() const;
 #endif
@@ -81,7 +73,7 @@ struct QContiguousCacheTypedData: private QContiguousCacheData
     // private inheritance to avoid aliasing warningss
     T array[1];
 
-    static inline void free(QContiguousCacheTypedData *data) { QContiguousCacheData::freeData(data); }
+    static inline void free(QContiguousCacheTypedData *data) { ::free(data); }
 };
 
 template<typename T>
@@ -160,21 +152,13 @@ public:
 private:
     void detach_helper();
 
-    QContiguousCacheData *malloc(int aalloc);
+    QContiguousCacheData *allocate(int aalloc);
     void free(Data *x);
     int sizeOfTypedData() {
         // this is more or less the same as sizeof(Data), except that it doesn't
         // count the padding at the end
         return reinterpret_cast<const char *>(&(reinterpret_cast<const Data *>(this))->array[1]) - reinterpret_cast<const char *>(this);
     }
-    int alignOfTypedData() const
-    {
-#ifdef Q_ALIGNOF
-        return qMax<int>(sizeof(void*), Q_ALIGNOF(Data));
-#else
-        return 0;
-#endif
-    }
 };
 
 template <typename T>
@@ -182,7 +166,7 @@ void QContiguousCache<T>::detach_helper()
 {
     union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
 
-    x.d = malloc(d->alloc);
+    x.d = allocate(d->alloc);
     x.d->ref = 1;
     x.d->count = d->count;
     x.d->start = d->start;
@@ -219,7 +203,7 @@ void QContiguousCache<T>::setCapacity(int asize)
         return;
     detach();
     union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
-    x.d = malloc(asize);
+    x.d = allocate(asize);
     x.d->alloc = asize;
     x.d->count = qMin(d->count, asize);
     x.d->offset = d->offset + d->count - x.d->count;
@@ -270,7 +254,7 @@ void QContiguousCache<T>::clear()
         d->count = d->start = d->offset = 0;
     } else {
         union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
-        x.d = malloc(d->alloc);
+        x.d = allocate(d->alloc);
         x.d->ref = 1;
         x.d->alloc = d->alloc;
         x.d->count = x.d->start = x.d->offset = 0;
@@ -281,15 +265,15 @@ void QContiguousCache<T>::clear()
 }
 
 template <typename T>
-inline QContiguousCacheData *QContiguousCache<T>::malloc(int aalloc)
+inline QContiguousCacheData *QContiguousCache<T>::allocate(int aalloc)
 {
-    return QContiguousCacheData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData());
+    return ::malloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T));
 }
 
 template <typename T>
 QContiguousCache<T>::QContiguousCache(int cap)
 {
-    d = malloc(cap);
+    d = allocate(cap);
     d->ref = 1;
     d->alloc = cap;
     d->count = d->start = d->offset = 0;
index 31520bd..5b22122 100644 (file)
@@ -1366,7 +1366,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
 
 /*!
     Converts this meta object builder into a concrete QMetaObject.
-    The return value should be deallocated using qFree() once it
+    The return value should be deallocated using free() once it
     is no longer needed.
 
     The returned meta object is a snapshot of the state of the