From 879539fb99f4cebd4ee53b8a42bb848a745ba36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 21 May 2012 14:41:54 +0200 Subject: [PATCH] Rename QVector::realloc and QVector::free. These names were confusing and conflicting with standard C memory management functions. Change-Id: I6efe20665d2ec7ad3e00f3a806cc1843a57374d4 Reviewed-by: Thiago Macieira --- src/corelib/tools/qvector.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 88a6744d11..e2cb7fbf23 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -73,7 +73,7 @@ public: explicit QVector(int size); QVector(int size, const T &t); inline QVector(const QVector &v); - inline ~QVector() { if (!d->ref.deref()) free(d); } + inline ~QVector() { if (!d->ref.deref()) freeData(d); } QVector &operator=(const QVector &v); #ifdef Q_COMPILER_RVALUE_REFS inline QVector(QVector &&other) : d(other.d) { other.d = Data::sharedNull(); } @@ -97,7 +97,7 @@ public: void reserve(int size); inline void squeeze() { - realloc(d->size, d->size); + reallocData(d->size, d->size); if (d->capacityReserved) { // capacity reserved in a read only memory would be useless // this checks avoid writing to such memory. @@ -220,8 +220,8 @@ public: private: friend class QRegion; // Optimization for QRegion::rects() - void realloc(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); - void free(Data *d); + void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); + void freeData(Data *d); void defaultConstruct(T *from, T *to); void copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom); void destruct(T *from, T *to); @@ -294,7 +294,7 @@ void QVector::detach() { if (!isDetached()) { if (d->alloc) - realloc(d->size, int(d->alloc)); + reallocData(d->size, int(d->alloc)); else d = Data::unsharableEmpty(); } @@ -305,7 +305,7 @@ template void QVector::reserve(int asize) { if (asize > int(d->alloc)) - realloc(d->size, asize); + reallocData(d->size, asize); if (isDetached()) d->capacityReserved = 1; Q_ASSERT(capacity() >= asize); @@ -327,7 +327,7 @@ void QVector::resize(int asize) } else { newAlloc = oldAlloc; } - realloc(asize, newAlloc, opt); + reallocData(asize, newAlloc, opt); } template inline void QVector::clear() @@ -421,14 +421,14 @@ QVector::QVector(std::initializer_list args) #endif template -void QVector::free(Data *x) +void QVector::freeData(Data *x) { destruct(x->begin(), x->end()); Data::deallocate(x); } template -void QVector::realloc(const int asize, const int aalloc, QArrayData::AllocationOptions options) +void QVector::reallocData(const int asize, const int aalloc, QArrayData::AllocationOptions options) { Q_ASSERT(asize >= 0 && asize <= aalloc); Data *x = d; @@ -499,7 +499,7 @@ void QVector::realloc(const int asize, const int aalloc, QArrayData::Allocati if (QTypeInfo::isStatic || !aalloc) { // data was copy constructed, we need to call destructors // or if !alloc we did nothing to the old 'd'. - free(d); + freeData(d); } else { Data::deallocate(d); } @@ -536,7 +536,7 @@ void QVector::append(const T &t) const bool isTooSmall = uint(d->size + 1) > d->alloc; if (!isDetached() || isTooSmall) { QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default); - realloc(d->size, isTooSmall ? d->size + 1 : d->alloc, opt); + reallocData(d->size, isTooSmall ? d->size + 1 : d->alloc, opt); } if (QTypeInfo::isComplex) new (d->end()) T(copy); @@ -552,7 +552,7 @@ typename QVector::iterator QVector::insert(iterator before, size_type n, c if (n != 0) { const T copy(t); if (!isDetached() || d->size + n > int(d->alloc)) - realloc(d->size, d->size + n, QArrayData::Grow); + reallocData(d->size, d->size + n, QArrayData::Grow); if (QTypeInfo::isStatic) { T *b = d->end(); T *i = d->end() + n; @@ -650,7 +650,7 @@ template QVector &QVector::operator+=(const QVector &l) { int newSize = d->size + l.d->size; - realloc(d->size, newSize); + reallocData(d->size, newSize); if (d->alloc) { T *w = d->begin() + newSize;