summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorHarald Fernengel <harald@trolltech.com>2009-08-07 13:08:09 (GMT)
committerHarald Fernengel <harald@trolltech.com>2009-08-07 13:10:36 (GMT)
commitdfa284220498a1e32ab3133f203bcb41cfa136b7 (patch)
treee6e8a6cae4b2195313258c5001100e2557c6463e /src/testlib/qtestcase.cpp
parent658c30c214070e8ff05ddaf1cb7b161c1b73f5ce (diff)
downloadQt-dfa284220498a1e32ab3133f203bcb41cfa136b7.zip
Qt-dfa284220498a1e32ab3133f203bcb41cfa136b7.tar.gz
Qt-dfa284220498a1e32ab3133f203bcb41cfa136b7.tar.bz2
Refactor QTestCharBuffer a bit
Use a static buffer for small strings, and making it oom safe. We can now see messages up to 512 bytes even if we run out of memory (important for OOM tests). Also, testlogging (< 512 bytes per line) should again work without a single allocation. Reviewed-By: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index ac4ca83..1866197 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -820,43 +820,6 @@ void filter_unprintable(char *str)
/*! \internal
*/
-int qt_asprintf(char **str, const char *format, ...)
-{
- static const int MAXSIZE = 1024*1024*2;
-
- int size = 32;
- delete[] *str;
- *str = new char[size];
-
- va_list ap;
- int res = 0;
-
- for (;;) {
- va_start(ap, format);
- res = qvsnprintf(*str, size, format, ap);
- va_end(ap);
- (*str)[size - 1] = '\0';
- if (res >= 0 && res < size) {
- // We succeeded
- break;
- }
- // buffer wasn't big enough, try again.
- // Note, we're assuming that a result of -1 is always due to running out of space.
- size *= 2;
- if (size > MAXSIZE) {
- break;
- }
- delete[] *str;
- *str = new char[size];
- }
-
- filter_unprintable(*str);
-
- return res;
-}
-
-/*! \internal
- */
int qt_snprintf(char *str, int size, const char *format, ...)
{
va_list ap;