diff options
author | hjk <qtc-committer@nokia.com> | 2009-06-18 14:36:46 (GMT) |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2009-06-19 06:39:38 (GMT) |
commit | cce29e63108827f551c74221d0aafbbba891dd51 (patch) | |
tree | 0060d9cb361cab7d64fed0f79e7673f1f620ce6a | |
parent | f9f08de9d41fd55d9c7d01578191ef5d4099c9e6 (diff) | |
download | Qt-cce29e63108827f551c74221d0aafbbba891dd51.zip Qt-cce29e63108827f551c74221d0aafbbba891dd51.tar.gz Qt-cce29e63108827f551c74221d0aafbbba891dd51.tar.bz2 |
New constructor QByteArray::QByteArray(int size, enum Qt::Uninitialized)
Contrary to the QByteArray::QByteArray(int size, enum Qt::Uninitialized)
constructor this does not initialize its data.
Reviewed-by: mariusSO
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 15 | ||||
-rw-r--r-- | src/corelib/tools/qbytearray.h | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 0c45776..142dfeb 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1304,6 +1304,21 @@ QByteArray::QByteArray(int size, char ch) } /*! + \internal + + Constructs a byte array of size \a size with uninitialized contents. +*/ + +QByteArray::QByteArray(int size, enum Qt::Uninitialized) +{ + d = static_cast<Data *>(qMalloc(sizeof(Data)+size)); + d->ref = 1; + d->alloc = d->size = size; + d->data = d->array; + d->array[size] = '\0'; +} + +/*! Sets the size of the byte array to \a size bytes. If \a size is greater than the current size, the byte array is diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 5cd4d63..3cb10d7 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -42,8 +42,8 @@ #ifndef QBYTEARRAY_H #define QBYTEARRAY_H -#include <QtCore/qglobal.h> #include <QtCore/qatomic.h> +#include <QtCore/qnamespace.h> #include <string.h> #include <stdarg.h> @@ -127,6 +127,7 @@ public: QByteArray(const char *); QByteArray(const char *, int size); QByteArray(int size, char c); + QByteArray(int size, enum Qt::Uninitialized); inline QByteArray(const QByteArray &); inline ~QByteArray(); |