From b3f12ea1d40b33e459c95317911251b8a8d5c3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 4 Apr 2012 14:24:01 +0200 Subject: 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 Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 2 +- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index a6bb6afe57..32834ebd7e 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -3886,7 +3886,7 @@ QByteArray QByteArray::fromRawData(const char *data, int size) } else if (!size) { x = shared_empty.data_ptr(); } else { - x = static_cast(malloc(sizeof(Data) + 1)); + x = static_cast(malloc(sizeof(Data))); Q_CHECK_PTR(x); x->ref.initializeOwned(); x->size = size; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 5e69a13057..710aec931a 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -7438,7 +7438,7 @@ QString QString::fromRawData(const QChar *unicode, int size) } else if (!size) { x = shared_empty.data_ptr(); } else { - x = static_cast(::malloc(sizeof(Data) + sizeof(ushort))); + x = static_cast(::malloc(sizeof(Data))); Q_CHECK_PTR(x); x->ref.initializeOwned(); x->size = size; -- cgit v1.2.3