diff options
author | Liang Qi <liang.qi@qt.io> | 2019-07-01 10:21:37 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-07-01 10:21:37 +0200 |
commit | d25c3227299a6a281db37e68e45f0b02db3f5297 (patch) | |
tree | 08f436f8aebe2c8aaaee570f88e71bd2d0c8f6e7 /src/corelib/tools | |
parent | 222b81f5dac2a5d32027b15d3a784819291431f6 (diff) | |
parent | a39b19b0c7419021b3c22dc4d4bced0995f3a29f (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/network/ssl/qsslsocket_openssl.cpp
src/platformsupport/vkconvenience/qvkconvenience.cpp
Change-Id: I97ce6ed185f7fdad8102cc58d3cfec0119fd7bb4
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 17 | ||||
-rw-r--r-- | src/corelib/tools/qiterator.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 18 | ||||
-rw-r--r-- | src/corelib/tools/qvector.qdoc | 18 |
4 files changed, 55 insertions, 2 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c25d39461f..ecbb4743af 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -943,6 +943,23 @@ QByteArray qUncompress(const uchar* data, int nbytes) and QByteArray() compares equal to QByteArray(""). We recommend that you always use isEmpty() and avoid isNull(). + \section1 Maximum size and out-of-memory conditions + + The current version of QByteArray is limited to just under 2 GB (2^31 + bytes) in size. The exact value is architecture-dependent, since it depends + on the overhead required for managing the data block, but is no more than + 32 bytes. Raw data blocks are also limited by the use of \c int type in the + current version to 2 GB minus 1 byte. + + In case memory allocation fails, QByteArray will throw a \c std::bad_alloc + exception. Out of memory conditions in the Qt containers are the only case + where Qt will throw exceptions. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the QByteArray API. + \section1 Notes on Locale \section2 Number-String Conversions diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 82212c3eb5..449d1049a0 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -115,11 +115,11 @@ template <class Key, class T> \ class Q##C##Iterator \ { \ typedef typename Q##C<Key,T>::const_iterator const_iterator; \ - typedef const_iterator Item; \ Q##C<Key,T> c; \ const_iterator i, n; \ inline bool item_exists() const { return n != c.constEnd(); } \ public: \ + typedef const_iterator Item; \ inline Q##C##Iterator(const Q##C<Key,T> &container) \ : c(container), i(c.constBegin()), n(c.constEnd()) {} \ inline Q##C##Iterator &operator=(const Q##C<Key,T> &container) \ @@ -148,11 +148,11 @@ class QMutable##C##Iterator \ { \ typedef typename Q##C<Key,T>::iterator iterator; \ typedef typename Q##C<Key,T>::const_iterator const_iterator; \ - typedef iterator Item; \ Q##C<Key,T> *c; \ iterator i, n; \ inline bool item_exists() const { return const_iterator(n) != c->constEnd(); } \ public: \ + typedef iterator Item; \ inline QMutable##C##Iterator(Q##C<Key,T> &container) \ : c(&container) \ { i = c->begin(); n = c->end(); } \ diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 319f82af53..47db97cdfc 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1739,6 +1739,24 @@ const QString::Null QString::null = { }; and the \c{'+'} will automatically be performed as the \c{QStringBuilder} \c{'%'} everywhere. + \section1 Maximum size and out-of-memory conditions + + The current version of QString is limited to just under 2 GB (2^31 bytes) + in size. The exact value is architecture-dependent, since it depends on the + overhead required for managing the data block, but is no more than 32 + bytes. Raw data blocks are also limited by the use of \c int type in the + current version to 2 GB minus 1 byte. Since QString uses two bytes per + character, that translates to just under 2^30 characters in one QString. + + In case memory allocation fails, QString will throw a \c std::bad_alloc + exception. Out of memory conditions in the Qt containers are the only case + where Qt will throw exceptions. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the Qt API. + \sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef */ diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc index 4c442511ea..8765b7fbd6 100644 --- a/src/corelib/tools/qvector.qdoc +++ b/src/corelib/tools/qvector.qdoc @@ -173,6 +173,24 @@ For a detailed discussion comparing Qt containers with each other and with STL containers, see \l {Understand the Qt Containers}. + \section1 Maximum size and out-of-memory conditions + + The current version of QVector is limited to just under 2 GB (2^31 bytes) + in size. The exact value is architecture-dependent, since it depends on the + overhead required for managing the data block, but is no more than 32 + bytes. The number of elements that can be stored in a QVector is that size + divided by the size of each element. + + In case memory allocation fails, QVector will use the \l Q_CHECK_PTR macro, + which will throw a \c std::bad_alloc exception if the application is being + compiled with exception support. If exceptions are disabled, then running + out of memory is undefined behavior. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the Qt API. + \sa QVectorIterator, QMutableVectorIterator, QList, QLinkedList */ |