Make QByteArray and QString keep track of terminating null
authorJoão Abecasis <joao.abecasis@nokia.com>
Wed, 4 Apr 2012 13:36:09 +0000 (15:36 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 16 Apr 2012 13:50:53 +0000 (15:50 +0200)
commit2ac4c463afdb8a62b0abb8ba444f34ca50e8979c
tree56be42941a0221e1aa9d325fb7d7d5ac0557873e
parent77fd8fd9977b987c99acba6417ac369a9975d989
Make QByteArray and QString keep track of terminating null

In conceptual terms, this change increments the Data::alloc member by
one for all strings allocated and maintained by these classes. Instances
initialized with fromRawData retain 0 as the member value, so they are
treated as immutable.

This brings QByteArray and QString closer to QVector, making it possible
for them to reference and share the same data in memory, in the future.
It also brings them closer to QArrayData.

In practical terms all comparisons to the alloc member were changed to
take into account that it also tracks the terminating null character.

Aside from the increment in the alloc member, there should be no user
visible changes.

Change-Id: I618f49022a9b1845754500c8f8706c72a68b9c7d
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qbytearray.cpp
src/corelib/tools/qbytearray.h
src/corelib/tools/qstring.cpp
src/corelib/tools/qstring.h