Don't allocate space for null when using fromRawData

In this case we only need to allocate space for the "header" data.

Change-Id: I059627e47a5bae7a02c82d837c826a6ed0fd20fd
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
João Abecasis 2012-04-04 14:24:01 +02:00 committed by Qt by Nokia
parent 98e50a18ed
commit b3f12ea1d4
2 changed files with 2 additions and 2 deletions

View File

@ -3886,7 +3886,7 @@ QByteArray QByteArray::fromRawData(const char *data, int size)
} else if (!size) {
x = shared_empty.data_ptr();
} else {
x = static_cast<Data *>(malloc(sizeof(Data) + 1));
x = static_cast<Data *>(malloc(sizeof(Data)));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = size;

View File

@ -7438,7 +7438,7 @@ QString QString::fromRawData(const QChar *unicode, int size)
} else if (!size) {
x = shared_empty.data_ptr();
} else {
x = static_cast<Data *>(::malloc(sizeof(Data) + sizeof(ushort)));
x = static_cast<Data *>(::malloc(sizeof(Data)));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = size;