Rename realloc -> reallocData

This avoids confusion with standard ::realloc.

Change-Id: Ibeccf2f702ec37161033febf4f3926bee8f7aea6
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
João Abecasis 2012-04-04 14:04:03 +02:00 committed by Qt by Nokia
parent e5d10b2a3b
commit 3669ceb779
4 changed files with 26 additions and 27 deletions

View File

@ -919,7 +919,7 @@ QByteArray &QByteArray::operator=(const char *str)
} else {
int len = strlen(str);
if (d->ref.isShared() || len > int(d->alloc) || (len < d->size && len < int(d->alloc) >> 1))
realloc(len);
reallocData(len);
x = d;
memcpy(x->data(), str, len + 1); // include null terminator
x->size = len;
@ -1432,7 +1432,7 @@ void QByteArray::resize(int size)
} else {
if (d->ref.isShared() || size > int(d->alloc)
|| (!d->capacityReserved && size < d->size && size < int(d->alloc) >> 1))
realloc(size, true);
reallocData(size, true);
if (int(d->alloc) >= size) {
d->size = size;
d->data()[size] = '\0';
@ -1459,7 +1459,7 @@ QByteArray &QByteArray::fill(char ch, int size)
return *this;
}
void QByteArray::realloc(int alloc, bool grow)
void QByteArray::reallocData(int alloc, bool grow)
{
if (grow)
alloc = qAllocMore(alloc + 1, sizeof(Data)) - 1;
@ -1566,7 +1566,7 @@ QByteArray &QByteArray::prepend(const char *str, int len)
{
if (str) {
if (d->ref.isShared() || d->size + len > int(d->alloc))
realloc(d->size + len, true);
reallocData(d->size + len, true);
memmove(d->data()+len, d->data(), d->size);
memcpy(d->data(), str, len);
d->size += len;
@ -1584,7 +1584,7 @@ QByteArray &QByteArray::prepend(const char *str, int len)
QByteArray &QByteArray::prepend(char ch)
{
if (d->ref.isShared() || d->size + 1 > int(d->alloc))
realloc(d->size + 1, true);
reallocData(d->size + 1, true);
memmove(d->data()+1, d->data(), d->size);
d->data()[0] = ch;
++d->size;
@ -1622,7 +1622,7 @@ QByteArray &QByteArray::append(const QByteArray &ba)
*this = ba;
} else if (ba.d != &shared_null.ba) {
if (d->ref.isShared() || d->size + ba.d->size > int(d->alloc))
realloc(d->size + ba.d->size, true);
reallocData(d->size + ba.d->size, true);
memcpy(d->data() + d->size, ba.d->data(), ba.d->size);
d->size += ba.d->size;
d->data()[d->size] = '\0';
@ -1656,7 +1656,7 @@ QByteArray& QByteArray::append(const char *str)
if (str) {
int len = strlen(str);
if (d->ref.isShared() || d->size + len > int(d->alloc))
realloc(d->size + len, true);
reallocData(d->size + len, true);
memcpy(d->data() + d->size, str, len + 1); // include null terminator
d->size += len;
}
@ -1681,7 +1681,7 @@ QByteArray &QByteArray::append(const char *str, int len)
len = qstrlen(str);
if (str && len) {
if (d->ref.isShared() || d->size + len > int(d->alloc))
realloc(d->size + len, true);
reallocData(d->size + len, true);
memcpy(d->data() + d->size, str, len); // include null terminator
d->size += len;
d->data()[d->size] = '\0';
@ -1698,7 +1698,7 @@ QByteArray &QByteArray::append(const char *str, int len)
QByteArray& QByteArray::append(char ch)
{
if (d->ref.isShared() || d->size + 1 > int(d->alloc))
realloc(d->size + 1, true);
reallocData(d->size + 1, true);
d->data()[d->size++] = ch;
d->data()[d->size] = '\0';
return *this;

View File

@ -406,7 +406,7 @@ private:
static const QStaticByteArrayData<1> shared_null;
static const QStaticByteArrayData<1> shared_empty;
Data *d;
void realloc(int alloc, bool grow = false);
void reallocData(int alloc, bool grow = false);
void expand(int i);
QByteArray nulTerminated() const;
@ -445,7 +445,7 @@ inline const char *QByteArray::data() const
inline const char *QByteArray::constData() const
{ return d->data(); }
inline void QByteArray::detach()
{ if (d->ref.isShared() || (d->offset != sizeof(QByteArrayData))) realloc(d->size); }
{ if (d->ref.isShared() || (d->offset != sizeof(QByteArrayData))) reallocData(d->size); }
inline bool QByteArray::isDetached() const
{ return !d->ref.isShared(); }
inline QByteArray::QByteArray(const QByteArray &a) : d(a.d)
@ -457,7 +457,7 @@ inline int QByteArray::capacity() const
inline void QByteArray::reserve(int asize)
{
if (d->ref.isShared() || asize > int(d->alloc))
realloc(asize);
reallocData(asize);
if (!d->capacityReserved) {
// cannot set unconditionally, since d could be the shared_null/shared_empty (which is const)
@ -468,7 +468,7 @@ inline void QByteArray::reserve(int asize)
inline void QByteArray::squeeze()
{
if (d->ref.isShared() || d->size < int(d->alloc))
realloc(d->size);
reallocData(d->size);
if (d->capacityReserved) {
// cannot set unconditionally, since d could be shared_null or

View File

@ -1242,7 +1242,7 @@ void QString::resize(int size)
} else {
if (d->ref.isShared() || size > int(d->alloc) ||
(!d->capacityReserved && size < d->size && size < int(d->alloc) >> 1))
realloc(size, true);
reallocData(size, true);
if (int(d->alloc) >= size) {
d->size = size;
d->data()[size] = '\0';
@ -1300,8 +1300,7 @@ void QString::resize(int size)
\sa reserve(), capacity()
*/
// ### Qt 5: rename reallocData() to avoid confusion. 197625
void QString::realloc(int alloc, bool grow)
void QString::reallocData(int alloc, bool grow)
{
if (grow)
alloc = qAllocMore((alloc+1) * sizeof(QChar), sizeof(Data)) / sizeof(QChar) - 1;
@ -1532,7 +1531,7 @@ QString &QString::append(const QString &str)
operator=(str);
} else {
if (d->ref.isShared() || d->size + str.d->size > int(d->alloc))
realloc(d->size + str.d->size, true);
reallocData(d->size + str.d->size, true);
memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar));
d->size += str.d->size;
d->data()[d->size] = '\0';
@ -1552,7 +1551,7 @@ QString &QString::append(const QLatin1String &str)
if (s) {
int len = str.size();
if (d->ref.isShared() || d->size + len > int(d->alloc))
realloc(d->size + len, true);
reallocData(d->size + len, true);
ushort *i = d->data() + d->size;
while ((*i++ = *s++))
;
@ -1595,7 +1594,7 @@ QString &QString::append(const QLatin1String &str)
QString &QString::append(QChar ch)
{
if (d->ref.isShared() || d->size + 1 > int(d->alloc))
realloc(d->size + 1, true);
reallocData(d->size + 1, true);
d->data()[d->size++] = ch.unicode();
d->data()[d->size] = '\0';
return *this;
@ -2816,7 +2815,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
if (isEmpty() && rx2.indexIn(*this) == -1)
return *this;
realloc(d->size);
reallocData(d->size);
int index = 0;
int numCaptures = rx2.captureCount();
@ -2979,7 +2978,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
if (!iterator.hasNext()) // no matches at all
return *this;
realloc(d->size);
reallocData(d->size);
int numCaptures = re.captureCount();
@ -5083,7 +5082,7 @@ const ushort *QString::utf16() const
{
if (IS_RAW_DATA(d)) {
// ensure '\0'-termination for ::fromRawData strings
const_cast<QString*>(this)->realloc(d->size);
const_cast<QString*>(this)->reallocData(d->size);
}
return d->data();
}

View File

@ -372,7 +372,7 @@ public:
inline QString &operator+=(QChar c) {
if (d->ref.isShared() || d->size + 1 > int(d->alloc))
realloc(d->size + 1, true);
reallocData(d->size + 1, true);
d->data()[d->size++] = c.unicode();
d->data()[d->size] = '\0';
return *this;
@ -650,7 +650,7 @@ private:
Data *d;
static void free(Data *);
void realloc(int alloc, bool grow = false);
void reallocData(int alloc, bool grow = false);
void expand(int i);
void updateProperties() const;
QString multiArg(int numArgs, const QString **args) const;
@ -746,7 +746,7 @@ inline QChar *QString::data()
inline const QChar *QString::constData() const
{ return reinterpret_cast<const QChar*>(d->data()); }
inline void QString::detach()
{ if (d->ref.isShared() || (d->offset != sizeof(QStringData))) realloc(d->size); }
{ if (d->ref.isShared() || (d->offset != sizeof(QStringData))) reallocData(d->size); }
inline bool QString::isDetached() const
{ return !d->ref.isShared(); }
inline QString &QString::operator=(const QLatin1String &s)
@ -912,7 +912,7 @@ inline QString::~QString() { if (!d->ref.deref()) free(d); }
inline void QString::reserve(int asize)
{
if (d->ref.isShared() || asize > int(d->alloc))
realloc(asize);
reallocData(asize);
if (!d->capacityReserved) {
// cannot set unconditionally, since d could be the shared_null/shared_empty (which is const)
@ -923,7 +923,7 @@ inline void QString::reserve(int asize)
inline void QString::squeeze()
{
if (d->ref.isShared() || d->size < int(d->alloc))
realloc(d->size);
reallocData(d->size);
if (d->capacityReserved) {
// cannot set unconditionally, since d could be shared_null or