diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-06-11 19:42:05 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-08 10:29:09 +0100 |
commit | 62c673ccc6f81cee09a25f5acceec2768cea4672 (patch) | |
tree | 883720fc4a6d333dbf3afb7b8276bbd33d202ffc /src/corelib/text/qbytearray.cpp | |
parent | a3aa2fcfa72ab69bdbded26dcd43e37b35796a17 (diff) |
Add reference-count manipulation functions to QArrayData and hide ref
The next change will stop using some values in the reference counter as
settings from the data.
Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index da91a93700..78395a47e3 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1184,8 +1184,8 @@ QByteArray qUncompress(const uchar* data, int nbytes) */ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept { - other.d->ref.ref(); - if (!d->ref.deref()) + other.d->ref(); + if (!d->deref()) Data::deallocate(d); d = other.d; return *this; @@ -1215,8 +1215,8 @@ QByteArray &QByteArray::operator=(const char *str) memcpy(x->data(), str, fullLen); // include null terminator x->size = len; } - x->ref.ref(); - if (!d->ref.deref()) + x->ref(); + if (!d->deref()) Data::deallocate(d); d = x; return *this; @@ -1755,12 +1755,12 @@ void QByteArray::resize(int size) if (size < 0) size = 0; - if (!d->ref.isShared() && !d->isMutable() && size < d->size) { + if (!d->isShared() && !d->isMutable() && size < d->size) { d->size = size; return; } - if (d->size == 0 && d->ref.isStatic()) { + if (d->size == 0 && d->isStatic()) { // // Optimize the idiom: // QByteArray a; @@ -1811,7 +1811,7 @@ void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) x->size = qMin(int(alloc) - 1, d->size); ::memcpy(x->data(), d->data(), x->size); x->data()[x->size] = '\0'; - if (!d->ref.deref()) + if (!d->deref()) Data::deallocate(d); d = x; } else { @@ -1869,7 +1869,7 @@ QByteArray QByteArray::nulTerminated() const QByteArray &QByteArray::prepend(const QByteArray &ba) { - if (d->size == 0 && d->ref.isStatic() && !IS_RAW_DATA(ba.d)) { + if (d->size == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.d->size != 0) { QByteArray tmp = *this; @@ -1961,7 +1961,7 @@ QByteArray &QByteArray::prepend(char ch) QByteArray &QByteArray::append(const QByteArray &ba) { - if (d->size == 0 && d->ref.isStatic() && !IS_RAW_DATA(ba.d)) { + if (d->size == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.d->size != 0) { if (d->needsDetach() || d->size + ba.d->size > capacity()) @@ -3239,7 +3239,7 @@ QByteArray QByteArray::toUpper_helper(QByteArray &a) void QByteArray::clear() { - if (!d->ref.deref()) + if (!d->deref()) Data::deallocate(d); d = Data::sharedNull(); } @@ -4471,7 +4471,7 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) { if (!data || !size) { clear(); - } else if (d->ref.isShared() || (d->flags & Data::RawDataType) == 0) { + } else if (d->isShared() || (d->flags & Data::RawDataType) == 0) { *this = fromRawData(data, size); } else { d->size = size; |