summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorRobin Burchell <robin+qt@viroteck.net>2012-03-22 21:44:13 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-31 16:46:40 +0200
commit47728445a5e7317ed2123a8824c54a012eeee142 (patch)
tree762385979cf489c0cb92a061ed7bde3cd077c851 /src/corelib/tools
parentad921347f701ea7f732633c9c584be9300317537 (diff)
Remove all calls to, and deprecate qMalloc, qRealloc and qFree.
Callers should just call the standard allocation functions directly. Adding an extra function call onto all basic memory management for the sake of making it instrumentable in rare cases isn't really fair to everyone else. What's more, this wasn't completely reliable, as not everything was using them in a number of places. Memory management can still be overridden using tricks like LD_PRELOAD if needed. Their aligned equivilents cannot be deprecated, as no standard equivilents exist, although investigation into posix_memalign(3) is a possibility for the future. Change-Id: Ic5f74b14be33f8bc188fe7236c55e15c36a23fc7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearray.h3
-rw-r--r--src/corelib/tools/qbytedata_p.h8
-rw-r--r--src/corelib/tools/qlist.h11
-rw-r--r--src/corelib/tools/qscopedpointer.h4
-rw-r--r--src/corelib/tools/qvarlengtharray.h11
5 files changed, 21 insertions, 16 deletions
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 1e70e26be3..31fa462ca4 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -45,6 +45,7 @@
#include <QtCore/qrefcount.h>
#include <QtCore/qnamespace.h>
+#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
@@ -402,7 +403,7 @@ public:
};
inline QByteArray::QByteArray(): d(const_cast<Data *>(&shared_null.ba)) { }
-inline QByteArray::~QByteArray() { if (!d->ref.deref()) qFree(d); }
+inline QByteArray::~QByteArray() { if (!d->ref.deref()) free(d); }
inline int QByteArray::size() const
{ return d->size; }
diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h
index 763b71c8f3..2deff997d2 100644
--- a/src/corelib/tools/qbytedata_p.h
+++ b/src/corelib/tools/qbytedata_p.h
@@ -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(byteAmount());
}
- // 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)
{
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index a15b0c9124..9d70e55b1e 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -55,6 +55,7 @@
#include <initializer_list>
#endif
+#include <stdlib.h>
#include <new>
#include <limits.h>
#include <string.h>
@@ -667,7 +668,7 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::Node *QList<T>::detach_helper_grow(int i
node_copy(reinterpret_cast<Node *>(p.begin()),
reinterpret_cast<Node *>(p.begin() + i), n);
} QT_CATCH(...) {
- qFree(d);
+ free(d);
d = x;
QT_RETHROW;
}
@@ -677,7 +678,7 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::Node *QList<T>::detach_helper_grow(int i
} QT_CATCH(...) {
node_destruct(reinterpret_cast<Node *>(p.begin()),
reinterpret_cast<Node *>(p.begin() + i));
- qFree(d);
+ free(d);
d = x;
QT_RETHROW;
}
@@ -696,7 +697,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper(int alloc)
QT_TRY {
node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n);
} QT_CATCH(...) {
- qFree(d);
+ free(d);
d = x;
QT_RETHROW;
}
@@ -721,7 +722,7 @@ Q_OUTOFLINE_TEMPLATE QList<T>::QList(const QList<T> &l)
struct Cleanup
{
Cleanup(QListData::Data *d) : d_(d) {}
- ~Cleanup() { if (d_) qFree(d_); }
+ ~Cleanup() { if (d_) free(d_); }
QListData::Data *d_;
} tryCatch(d);
@@ -763,7 +764,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::dealloc(QListData::Data *data)
{
node_destruct(reinterpret_cast<Node *>(data->array + data->begin),
reinterpret_cast<Node *>(data->array + data->end));
- qFree(data);
+ free(data);
}
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 4e1027e86a..c01a623414 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -44,6 +44,8 @@
#include <QtCore/qglobal.h>
+#include <stdlib.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -79,7 +81,7 @@ struct QScopedPointerArrayDeleter
struct QScopedPointerPodDeleter
{
- static inline void cleanup(void *pointer) { if (pointer) qFree(pointer); }
+ static inline void cleanup(void *pointer) { if (pointer) free(pointer); }
};
template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 4e042f765e..6ce6573843 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -48,6 +48,7 @@
#include <new>
#include <string.h>
+#include <stdlib.h>
QT_BEGIN_HEADER
@@ -77,7 +78,7 @@ public:
i->~T();
}
if (ptr != reinterpret_cast<T *>(array))
- qFree(ptr);
+ free(ptr);
}
inline QVarLengthArray<T, Prealloc> &operator=(const QVarLengthArray<T, Prealloc> &other)
{
@@ -190,7 +191,7 @@ template <class T, int Prealloc>
Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(int asize)
: s(asize) {
if (s > Prealloc) {
- ptr = reinterpret_cast<T *>(qMalloc(s * sizeof(T)));
+ ptr = reinterpret_cast<T *>(malloc(s * sizeof(T)));
Q_CHECK_PTR(ptr);
a = s;
} else {
@@ -243,7 +244,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
const int copySize = qMin(asize, osize);
if (aalloc != a) {
- ptr = reinterpret_cast<T *>(qMalloc(aalloc * sizeof(T)));
+ ptr = reinterpret_cast<T *>(malloc(aalloc * sizeof(T)));
Q_CHECK_PTR(ptr);
if (ptr) {
s = 0;
@@ -263,7 +264,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
while (sClean < osize)
(oldPtr+(sClean++))->~T();
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
- qFree(oldPtr);
+ free(oldPtr);
QT_RETHROW;
}
} else {
@@ -283,7 +284,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
}
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
- qFree(oldPtr);
+ free(oldPtr);
if (QTypeInfo<T>::isComplex) {
// call default constructor for new objects (which can throw)