tools/qbytearray.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13int qFindByteArray( -
14 const char *haystack0, int haystackLen, int from, -
15 const char *needle0, int needleLen); -
16 -
17 -
18int qAllocMore(int alloc, int extra) -
19{ -
20 qt_noop(); -
21 qt_noop(); -
22 -
23 unsigned nalloc = alloc + extra; -
24 -
25 -
26 -
27 -
28 -
29 -
30 nalloc |= nalloc >> 1; -
31 nalloc |= nalloc >> 2; -
32 nalloc |= nalloc >> 4; -
33 nalloc |= nalloc >> 8; -
34 nalloc |= nalloc >> 16; -
35 ++nalloc; -
36 -
37 qt_noop(); -
38 -
39 return nalloc - extra;
executed: return nalloc - extra;
Execution Count:20272755
20272755
40} -
41char *qstrdup(const char *src) -
42{ -
43 if (!src)
evaluated: !src
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1270237
1-1270237
44 return 0;
executed: return 0;
Execution Count:1
1
45 char *dst = new char[strlen(src) + 1]; -
46 return qstrcpy(dst, src);
executed: return qstrcpy(dst, src);
Execution Count:1270237
1270237
47} -
48char *qstrcpy(char *dst, const char *src) -
49{ -
50 if (!src)
evaluated: !src
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1271446
2-1271446
51 return 0;
executed: return 0;
Execution Count:2
2
52 return strcpy(dst, src);
executed: return strcpy(dst, src);
Execution Count:1271446
1271446
53 -
54} -
55char *qstrncpy(char *dst, const char *src, uint len) -
56{ -
57 if (!src || !dst)
evaluated: !src
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:19
partially evaluated: !dst
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
58 return 0;
executed: return 0;
Execution Count:2
2
59 -
60 -
61 -
62 strncpy(dst, src, len); -
63 -
64 if (len > 0)
partially evaluated: len > 0
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-19
65 dst[len-1] = '\0';
executed: dst[len-1] = '\0';
Execution Count:19
19
66 return dst;
executed: return dst;
Execution Count:19
19
67} -
68int qstrcmp(const char *str1, const char *str2) -
69{ -
70 return (str1 && str2) ? strcmp(str1, str2) 247040
71 : (str1 ? 1 : (str2 ? -1 : 0));
executed: return (str1 && str2) ? strcmp(str1, str2) : (str1 ? 1 : (str2 ? -1 : 0));
Execution Count:247040
247040
72} -
73int qstricmp(const char *str1, const char *str2) -
74{ -
75 register const uchar *s1 = reinterpret_cast<const uchar *>(str1); -
76 register const uchar *s2 = reinterpret_cast<const uchar *>(str2); -
77 int res; -
78 uchar c; -
79 if (!s1 || !s2)
evaluated: !s1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:114495
evaluated: !s2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:114494
1-114495
80 return s1 ? 1 : (s2 ? -1 : 0);
executed: return s1 ? 1 : (s2 ? -1 : 0);
Execution Count:3
3
81 for (; !(res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2)); s1++, s2++)
evaluated: !(res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2))
TRUEFALSE
yes
Evaluation Count:191633
yes
Evaluation Count:105873
105873-191633
82 if (!c)
evaluated: !c
TRUEFALSE
yes
Evaluation Count:8620
yes
Evaluation Count:183015
8620-183015
83 break;
executed: break;
Execution Count:8620
8620
84 return res;
executed: return res;
Execution Count:114490
114490
85} -
86int qstrnicmp(const char *str1, const char *str2, uint len) -
87{ -
88 register const uchar *s1 = reinterpret_cast<const uchar *>(str1); -
89 register const uchar *s2 = reinterpret_cast<const uchar *>(str2); -
90 int res; -
91 uchar c; -
92 if (!s1 || !s2)
evaluated: !s1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:123
evaluated: !s2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:122
1-123
93 return s1 ? 1 : (s2 ? -1 : 0);
executed: return s1 ? 1 : (s2 ? -1 : 0);
Execution Count:3
3
94 for (; len--; s1++, s2++) {
evaluated: len--
TRUEFALSE
yes
Evaluation Count:243
yes
Evaluation Count:10
10-243
95 if ((res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2)))
evaluated: (res = (c = QChar::toLower((ushort)*s1)) - QChar::toLower((ushort)*s2))
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:132
111-132
96 return res;
executed: return res;
Execution Count:111
111
97 if (!c)
evaluated: !c
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:131
1-131
98 break;
executed: break;
Execution Count:1
1
99 }
executed: }
Execution Count:131
131
100 return 0;
executed: return 0;
Execution Count:11
11
101} -
102 -
103 -
104 -
105 -
106int qstrcmp(const QByteArray &str1, const char *str2) -
107{ -
108 if (!str2)
evaluated: !str2
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:1556794
32-1556794
109 return str1.isEmpty() ? 0 : +1;
executed: return str1.isEmpty() ? 0 : +1;
Execution Count:32
32
110 -
111 const char *str1data = str1.constData(); -
112 const char *str1end = str1data + str1.length(); -
113 for ( ; str1data < str1end && *str2; ++str1data, ++str2) {
evaluated: str1data < str1end
TRUEFALSE
yes
Evaluation Count:5228338
yes
Evaluation Count:419018
evaluated: *str2
TRUEFALSE
yes
Evaluation Count:5228059
yes
Evaluation Count:280
280-5228338
114 register int diff = int(uchar(*str1data)) - uchar(*str2); -
115 if (diff)
evaluated: diff
TRUEFALSE
yes
Evaluation Count:1137494
yes
Evaluation Count:4090563
1137494-4090563
116 -
117 return diff;
executed: return diff;
Execution Count:1137494
1137494
118 }
executed: }
Execution Count:4090564
4090564
119 -
120 -
121 if (*str2 != '\0')
evaluated: *str2 != '\0'
TRUEFALSE
yes
Evaluation Count:1697
yes
Evaluation Count:417601
1697-417601
122 -
123 return -1;
executed: return -1;
Execution Count:1697
1697
124 if (str1data < str1end)
evaluated: str1data < str1end
TRUEFALSE
yes
Evaluation Count:280
yes
Evaluation Count:417321
280-417321
125 -
126 return +1;
executed: return +1;
Execution Count:280
280
127 return 0;
executed: return 0;
Execution Count:417321
417321
128} -
129 -
130 -
131 -
132 -
133int qstrcmp(const QByteArray &str1, const QByteArray &str2) -
134{ -
135 int l1 = str1.length(); -
136 int l2 = str2.length(); -
137 int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2)); -
138 if (ret != 0)
evaluated: ret != 0
TRUEFALSE
yes
Evaluation Count:30290
yes
Evaluation Count:1197
1197-30290
139 return ret;
executed: return ret;
Execution Count:30290
30290
140 -
141 -
142 -
143 return l1 - l2;
executed: return l1 - l2;
Execution Count:1197
1197
144} -
145static const quint16 crc_tbl[16] = { -
146 0x0000, 0x1081, 0x2102, 0x3183, -
147 0x4204, 0x5285, 0x6306, 0x7387, -
148 0x8408, 0x9489, 0xa50a, 0xb58b, -
149 0xc60c, 0xd68d, 0xe70e, 0xf78f -
150}; -
151quint16 qChecksum(const char *data, uint len) -
152{ -
153 register quint16 crc = 0xffff; -
154 uchar c; -
155 const uchar *p = reinterpret_cast<const uchar *>(data); -
156 while (len--) {
evaluated: len--
TRUEFALSE
yes
Evaluation Count:5933
yes
Evaluation Count:21
21-5933
157 c = *p++; -
158 crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)]; -
159 c >>= 4; -
160 crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)]; -
161 }
executed: }
Execution Count:5933
5933
162 return ~crc & 0xffff;
executed: return ~crc & 0xffff;
Execution Count:21
21
163} -
164QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel) -
165{ -
166 if (nbytes == 0) {
evaluated: nbytes == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-18
167 return QByteArray(4, '\0');
executed: return QByteArray(4, '\0');
Execution Count:1
1
168 } -
169 if (!data) {
partially evaluated: !data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
170 QMessageLogger("tools/qbytearray.cpp", 460, __PRETTY_FUNCTION__).warning("qCompress: Data is null"); -
171 return QByteArray();
never executed: return QByteArray();
0
172 } -
173 if (compressionLevel < -1 || compressionLevel > 9)
partially evaluated: compressionLevel < -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
partially evaluated: compressionLevel > 9
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
174 compressionLevel = -1;
never executed: compressionLevel = -1;
0
175 -
176 ulong len = nbytes + nbytes / 100 + 13; -
177 QByteArray bazip; -
178 int res; -
179 do { -
180 bazip.resize(len + 4); -
181 res = ::compress2((uchar*)bazip.data()+4, &len, (uchar*)data, nbytes, compressionLevel); -
182 -
183 switch (res) { -
184 case 0: -
185 bazip.resize(len + 4); -
186 bazip[0] = (nbytes & 0xff000000) >> 24; -
187 bazip[1] = (nbytes & 0x00ff0000) >> 16; -
188 bazip[2] = (nbytes & 0x0000ff00) >> 8; -
189 bazip[3] = (nbytes & 0x000000ff); -
190 break;
executed: break;
Execution Count:18
18
191 case (-4): -
192 QMessageLogger("tools/qbytearray.cpp", 482, __PRETTY_FUNCTION__).warning("qCompress: Z_MEM_ERROR: Not enough memory"); -
193 bazip.resize(0); -
194 break;
never executed: break;
0
195 case (-5): -
196 len *= 2; -
197 break;
never executed: break;
0
198 } -
199 } while (res == (-5));
executed: }
Execution Count:18
partially evaluated: res == (-5)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
200 -
201 return bazip;
executed: return bazip;
Execution Count:18
18
202} -
203QByteArray qUncompress(const uchar* data, int nbytes) -
204{ -
205 if (!data) {
partially evaluated: !data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:668
0-668
206 QMessageLogger("tools/qbytearray.cpp", 530, __PRETTY_FUNCTION__).warning("qUncompress: Data is null"); -
207 return QByteArray();
never executed: return QByteArray();
0
208 } -
209 if (nbytes <= 4) {
evaluated: nbytes <= 4
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:655
13-655
210 if (nbytes < 4 || (data[0]!=0 || data[1]!=0 || data[2]!=0 || data[3]!=0))
partially evaluated: nbytes < 4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
evaluated: data[0]!=0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
partially evaluated: data[1]!=0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: data[2]!=0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
evaluated: data[3]!=0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
0-13
211 QMessageLogger("tools/qbytearray.cpp", 535, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted");
executed: QMessageLogger("tools/qbytearray.cpp", 535, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted");
Execution Count:11
11
212 return QByteArray();
executed: return QByteArray();
Execution Count:13
13
213 } -
214 ulong expectedSize = (data[0] << 24) | (data[1] << 16) | -
215 (data[2] << 8) | (data[3] ); -
216 ulong len = qMax(expectedSize, 1ul); -
217 QScopedPointer<QByteArray::Data, QScopedPointerPodDeleter> d; -
218 -
219 for(;;) { -
220 ulong alloc = len; -
221 if (len >= (1u << 31u) - sizeof(QByteArray::Data)) {
evaluated: len >= (1u << 31u) - sizeof(QByteArray::Data)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:648
7-648
222 -
223 QMessageLogger("tools/qbytearray.cpp", 547, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted"); -
224 return QByteArray();
executed: return QByteArray();
Execution Count:7
7
225 } -
226 QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + alloc + 1)); -
227 if (!p) {
partially evaluated: !p
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:648
0-648
228 -
229 QMessageLogger("tools/qbytearray.cpp", 553, __PRETTY_FUNCTION__).warning("qUncompress: could not allocate enough memory to uncompress data"); -
230 return QByteArray();
never executed: return QByteArray();
0
231 } -
232 d.take(); -
233 d.reset(p); -
234 d->offset = sizeof(QByteArrayData); -
235 -
236 int res = ::uncompress((uchar*)d->data(), &len, -
237 (uchar*)data+4, nbytes-4); -
238 -
239 switch (res) { -
240 case 0: -
241 if (len != alloc) {
partially evaluated: len != alloc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:643
0-643
242 if (len >= (1u << 31u) - sizeof(QByteArray::Data)) {
never evaluated: len >= (1u << 31u) - sizeof(QByteArray::Data)
0
243 -
244 QMessageLogger("tools/qbytearray.cpp", 568, __PRETTY_FUNCTION__).warning("qUncompress: Input data is corrupted"); -
245 return QByteArray();
never executed: return QByteArray();
0
246 } -
247 QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + len + 1)); -
248 if (!p) {
never evaluated: !p
0
249 -
250 QMessageLogger("tools/qbytearray.cpp", 574, __PRETTY_FUNCTION__).warning("qUncompress: could not allocate enough memory to uncompress data"); -
251 return QByteArray();
never executed: return QByteArray();
0
252 } -
253 d.take(); -
254 d.reset(p); -
255 }
never executed: }
0
256 d->ref.initializeOwned(); -
257 d->size = len; -
258 d->alloc = uint(len) + 1u; -
259 d->capacityReserved = false; -
260 d->offset = sizeof(QByteArrayData); -
261 d->data()[len] = 0; -
262 -
263 { -
264 QByteArrayDataPtr dataPtr = { reinterpret_cast<QByteArrayData *>(d.take()) }; -
265 return QByteArray(dataPtr);
executed: return QByteArray(dataPtr);
Execution Count:643
643
266 } -
267 -
268 case (-4): -
269 QMessageLogger("tools/qbytearray.cpp", 593, __PRETTY_FUNCTION__).warning("qUncompress: Z_MEM_ERROR: Not enough memory"); -
270 return QByteArray();
never executed: return QByteArray();
0
271 -
272 case (-5): -
273 len *= 2; -
274 continue;
never executed: continue;
0
275 -
276 case (-3): -
277 QMessageLogger("tools/qbytearray.cpp", 601, __PRETTY_FUNCTION__).warning("qUncompress: Z_DATA_ERROR: Input data is corrupted"); -
278 return QByteArray();
executed: return QByteArray();
Execution Count:5
5
279 } -
280 }
never executed: }
0
281}
never executed: }
0
282 -
283 -
284static inline bool qIsUpper(char c) -
285{ -
286 return c >= 'A' && c <= 'Z';
executed: return c >= 'A' && c <= 'Z';
Execution Count:450222
450222
287} -
288 -
289static inline char qToLower(char c) -
290{ -
291 if (c >= 'A' && c <= 'Z')
partially evaluated: c >= 'A'
TRUEFALSE
yes
Evaluation Count:450222
no
Evaluation Count:0
partially evaluated: c <= 'Z'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:450222
0-450222
292 return c - 'A' + 'a';
never executed: return c - 'A' + 'a';
0
293 else -
294 return c;
executed: return c;
Execution Count:450222
450222
295} -
296QByteArray &QByteArray::operator=(const QByteArray & other) -
297{ -
298 other.d->ref.ref(); -
299 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:230964
yes
Evaluation Count:956841
230964-956841
300 Data::deallocate(d);
executed: Data::deallocate(d);
Execution Count:230964
230964
301 d = other.d; -
302 return *this;
executed: return *this;
Execution Count:1187810
1187810
303} -
304QByteArray &QByteArray::operator=(const char *str) -
305{ -
306 Data *x; -
307 if (!str) {
evaluated: !str
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:212929
1-212929
308 x = Data::sharedNull(); -
309 } else if (!*str) {
executed: }
Execution Count:1
evaluated: !*str
TRUEFALSE
yes
Evaluation Count:46584
yes
Evaluation Count:166345
1-166345
310 x = Data::allocate(0); -
311 } else {
executed: }
Execution Count:46584
46584
312 const int len = int(strlen(str)); -
313 const uint fullLen = len + 1; -
314 if (d->ref.isShared() || fullLen > d->alloc
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:1860
yes
Evaluation Count:164485
evaluated: fullLen > d->alloc
TRUEFALSE
yes
Evaluation Count:82993
yes
Evaluation Count:81492
1860-164485
315 || (len < d->size && fullLen < uint(d->alloc >> 1)))
evaluated: len < d->size
TRUEFALSE
yes
Evaluation Count:13448
yes
Evaluation Count:68044
evaluated: fullLen < uint(d->alloc >> 1)
TRUEFALSE
yes
Evaluation Count:13445
yes
Evaluation Count:3
3-68044
316 reallocData(fullLen, d->detachFlags());
executed: reallocData(fullLen, d->detachFlags());
Execution Count:98298
98298
317 x = d; -
318 memcpy(x->data(), str, fullLen); -
319 x->size = len; -
320 }
executed: }
Execution Count:166345
166345
321 x->ref.ref(); -
322 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:45312
yes
Evaluation Count:167618
45312-167618
323 Data::deallocate(d);
executed: Data::deallocate(d);
Execution Count:45312
45312
324 d = x; -
325 return *this;
executed: return *this;
Execution Count:212930
212930
326} -
327void QByteArray::truncate(int pos) -
328{ -
329 if (pos < d->size)
evaluated: pos < d->size
TRUEFALSE
yes
Evaluation Count:22579
yes
Evaluation Count:864
864-22579
330 resize(pos);
executed: resize(pos);
Execution Count:22579
22579
331}
executed: }
Execution Count:23443
23443
332void QByteArray::chop(int n) -
333{ -
334 if (n > 0)
evaluated: n > 0
TRUEFALSE
yes
Evaluation Count:4094
yes
Evaluation Count:1
1-4094
335 resize(d->size - n);
executed: resize(d->size - n);
Execution Count:4094
4094
336}
executed: }
Execution Count:4095
4095
337QByteArray::QByteArray(const char *data, int size) -
338{ -
339 if (!data) {
evaluated: !data
TRUEFALSE
yes
Evaluation Count:409689
yes
Evaluation Count:4815639
409689-4815639
340 d = Data::sharedNull(); -
341 } else {
executed: }
Execution Count:409689
409689
342 if (size < 0)
evaluated: size < 0
TRUEFALSE
yes
Evaluation Count:2113642
yes
Evaluation Count:2702018
2113642-2702018
343 size = int(strlen(data));
executed: size = int(strlen(data));
Execution Count:2113642
2113642
344 if (!size) {
evaluated: !size
TRUEFALSE
yes
Evaluation Count:5949
yes
Evaluation Count:4809697
5949-4809697
345 d = Data::allocate(0); -
346 } else {
executed: }
Execution Count:5949
5949
347 d = Data::allocate(uint(size) + 1u); -
348 do { if (!(d)) qBadAlloc(); } while (0);
partially evaluated: !(d)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4809722
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4809712
never executed: qBadAlloc();
executed: }
Execution Count:4809715
0-4809722
349 d->size = size; -
350 memcpy(d->data(), data, size); -
351 d->data()[size] = '\0'; -
352 }
executed: }
Execution Count:4809711
4809711
353 } -
354} -
355QByteArray::QByteArray(int size, char ch) -
356{ -
357 if (size <= 0) {
evaluated: size <= 0
TRUEFALSE
yes
Evaluation Count:1198
yes
Evaluation Count:757287
1198-757287
358 d = Data::allocate(0); -
359 } else {
executed: }
Execution Count:1198
1198
360 d = Data::allocate(uint(size) + 1u); -
361 do { if (!(d)) qBadAlloc(); } while (0);
partially evaluated: !(d)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:757287
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:757287
never executed: qBadAlloc();
executed: }
Execution Count:757287
0-757287
362 d->size = size; -
363 memset(d->data(), ch, size); -
364 d->data()[size] = '\0'; -
365 }
executed: }
Execution Count:757287
757287
366} -
367 -
368 -
369 -
370 -
371 -
372 -
373 -
374QByteArray::QByteArray(int size, Qt::Initialization) -
375{ -
376 d = Data::allocate(uint(size) + 1u); -
377 do { if (!(d)) qBadAlloc(); } while (0);
partially evaluated: !(d)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1644476
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1644475
never executed: qBadAlloc();
executed: }
Execution Count:1644475
0-1644476
378 d->size = size; -
379 d->data()[size] = '\0'; -
380}
executed: }
Execution Count:1644476
1644476
381void QByteArray::resize(int size) -
382{ -
383 if (size < 0)
evaluated: size < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:26058655
3-26058655
384 size = 0;
executed: size = 0;
Execution Count:3
3
385 -
386 if (((d)->offset != sizeof(QByteArrayData)) && !d->ref.isShared() && size < d->size) {
evaluated: ((d)->offset != sizeof(QByteArrayData))
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:26058641
evaluated: !d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
partially evaluated: size < d->size
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-26058641
387 d->size = size; -
388 return;
executed: return;
Execution Count:1
1
389 } -
390 -
391 if (size == 0 && !d->capacityReserved) {
evaluated: size == 0
TRUEFALSE
yes
Evaluation Count:142782
yes
Evaluation Count:25915878
evaluated: !d->capacityReserved
TRUEFALSE
yes
Evaluation Count:142781
yes
Evaluation Count:1
1-25915878
392 Data *x = Data::allocate(0); -
393 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:81207
yes
Evaluation Count:61576
61576-81207
394 Data::deallocate(d);
executed: Data::deallocate(d);
Execution Count:81206
81206
395 d = x; -
396 } else if (d->size == 0 && d->ref.isStatic()) {
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:20236244
yes
Evaluation Count:5679645
evaluated: d->ref.isStatic()
TRUEFALSE
yes
Evaluation Count:19878665
yes
Evaluation Count:357581
executed: }
Execution Count:142780
142780-20236244
397 Data *x = Data::allocate(uint(size) + 1u); -
398 do { if (!(x)) qBadAlloc(); } while (0);
partially evaluated: !(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19878674
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19878670
never executed: qBadAlloc();
executed: }
Execution Count:19878671
0-19878674
399 x->size = size; -
400 x->data()[size] = '\0'; -
401 d = x; -
402 } else {
executed: }
Execution Count:19878673
19878673
403 if (d->ref.isShared() || uint(size) + 1u > d->alloc
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:6037032
evaluated: uint(size) + 1u > d->alloc
TRUEFALSE
yes
Evaluation Count:1584077
yes
Evaluation Count:4452956
193-6037032
404 || (!d->capacityReserved && size < d->size
evaluated: !d->capacityReserved
TRUEFALSE
yes
Evaluation Count:3510760
yes
Evaluation Count:942196
evaluated: size < d->size
TRUEFALSE
yes
Evaluation Count:2531109
yes
Evaluation Count:979650
942196-3510760
405 && uint(size) + 1u < uint(d->alloc >> 1)))
evaluated: uint(size) + 1u < uint(d->alloc >> 1)
TRUEFALSE
yes
Evaluation Count:1845990
yes
Evaluation Count:685120
685120-1845990
406 reallocData(uint(size) + 1u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(size) + 1u, d->detachFlags() | Data::Grow);
Execution Count:3430260
3430260
407 if (d->alloc) {
partially evaluated: d->alloc
TRUEFALSE
yes
Evaluation Count:6037226
no
Evaluation Count:0
0-6037226
408 d->size = size; -
409 d->data()[size] = '\0'; -
410 }
executed: }
Execution Count:6037226
6037226
411 }
executed: }
Execution Count:6037226
6037226
412} -
413QByteArray &QByteArray::fill(char ch, int size) -
414{ -
415 resize(size < 0 ? d->size : size); -
416 if (d->size)
partially evaluated: d->size
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
417 memset(d->data(), ch, d->size);
executed: memset(d->data(), ch, d->size);
Execution Count:4
4
418 return *this;
executed: return *this;
Execution Count:4
4
419} -
420 -
421void QByteArray::reallocData(uint alloc, Data::AllocationOptions options) -
422{ -
423 if (d->ref.isShared() || ((d)->offset != sizeof(QByteArrayData))) {
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:2558049
yes
Evaluation Count:4035616
evaluated: ((d)->offset != sizeof(QByteArrayData))
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4035610
5-4035616
424 Data *x = Data::allocate(alloc, options); -
425 do { if (!(x)) qBadAlloc(); } while (0);
partially evaluated: !(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2558094
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2558083
never executed: qBadAlloc();
executed: }
Execution Count:2558085
0-2558094
426 x->size = qMin(int(alloc) - 1, d->size); -
427 ::memcpy(x->data(), d->data(), x->size); -
428 x->data()[x->size] = '\0'; -
429 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2558098
5-2558098
430 Data::deallocate(d);
executed: Data::deallocate(d);
Execution Count:5
5
431 d = x; -
432 } else {
executed: }
Execution Count:2558101
2558101
433 if (options & Data::Grow)
evaluated: options & Data::Grow
TRUEFALSE
yes
Evaluation Count:3932580
yes
Evaluation Count:103025
103025-3932580
434 alloc = qAllocMore(alloc, sizeof(Data));
executed: alloc = qAllocMore(alloc, sizeof(Data));
Execution Count:3932585
3932585
435 Data *x = static_cast<Data *>(::realloc(d, sizeof(Data) + alloc)); -
436 do { if (!(x)) qBadAlloc(); } while (0);
partially evaluated: !(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4035615
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4035616
never executed: qBadAlloc();
executed: }
Execution Count:4035615
0-4035616
437 x->alloc = alloc; -
438 x->capacityReserved = (options & Data::CapacityReserved) ? 1 : 0;
evaluated: (options & Data::CapacityReserved)
TRUEFALSE
yes
Evaluation Count:12708
yes
Evaluation Count:4022908
12708-4022908
439 d = x; -
440 }
executed: }
Execution Count:4035613
4035613
441} -
442 -
443void QByteArray::expand(int i) -
444{ -
445 resize(qMax(i + 1, d->size)); -
446}
executed: }
Execution Count:940294
940294
447QByteArray QByteArray::nulTerminated() const -
448{ -
449 -
450 if (!((d)->offset != sizeof(QByteArrayData)))
evaluated: !((d)->offset != sizeof(QByteArrayData))
TRUEFALSE
yes
Evaluation Count:184567
yes
Evaluation Count:6
6-184567
451 return *this;
executed: return *this;
Execution Count:184567
184567
452 -
453 QByteArray copy(*this); -
454 copy.detach(); -
455 return copy;
executed: return copy;
Execution Count:6
6
456} -
457QByteArray &QByteArray::prepend(const QByteArray &ba) -
458{ -
459 if (d->size == 0 && d->ref.isStatic() && !((ba.d)->offset != sizeof(QByteArrayData))) {
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:425
partially evaluated: d->ref.isStatic()
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
evaluated: !((ba.d)->offset != sizeof(QByteArrayData))
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
0-425
460 *this = ba; -
461 } else if (ba.d->size != 0) {
executed: }
Execution Count:14
evaluated: ba.d->size != 0
TRUEFALSE
yes
Evaluation Count:300
yes
Evaluation Count:133
14-300
462 QByteArray tmp = *this; -
463 *this = ba; -
464 append(tmp); -
465 }
executed: }
Execution Count:300
300
466 return *this;
executed: return *this;
Execution Count:447
447
467} -
468 -
469 -
470 -
471 -
472 -
473 -
474 -
475QByteArray &QByteArray::prepend(const char *str) -
476{ -
477 return prepend(str, qstrlen(str));
executed: return prepend(str, qstrlen(str));
Execution Count:1307
1307
478} -
479QByteArray &QByteArray::prepend(const char *str, int len) -
480{ -
481 if (str) {
evaluated: str
TRUEFALSE
yes
Evaluation Count:1307
yes
Evaluation Count:9
9-1307
482 if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc)
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:182
yes
Evaluation Count:1125
evaluated: uint(d->size + len) + 1u > d->alloc
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:1087
38-1125
483 reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
Execution Count:220
220
484 memmove(d->data()+len, d->data(), d->size); -
485 memcpy(d->data(), str, len); -
486 d->size += len; -
487 d->data()[d->size] = '\0'; -
488 }
executed: }
Execution Count:1307
1307
489 return *this;
executed: return *this;
Execution Count:1316
1316
490} -
491 -
492 -
493 -
494 -
495 -
496 -
497 -
498QByteArray &QByteArray::prepend(char ch) -
499{ -
500 if (d->ref.isShared() || uint(d->size) + 2u > d->alloc)
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:664
evaluated: uint(d->size) + 2u > d->alloc
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:621
43-664
501 reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow);
Execution Count:98
98
502 memmove(d->data()+1, d->data(), d->size); -
503 d->data()[0] = ch; -
504 ++d->size; -
505 d->data()[d->size] = '\0'; -
506 return *this;
executed: return *this;
Execution Count:719
719
507} -
508QByteArray &QByteArray::append(const QByteArray &ba) -
509{ -
510 if (d->size == 0 && d->ref.isStatic() && !((ba.d)->offset != sizeof(QByteArrayData))) {
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:229690
yes
Evaluation Count:5544704
evaluated: d->ref.isStatic()
TRUEFALSE
yes
Evaluation Count:208212
yes
Evaluation Count:21481
evaluated: !((ba.d)->offset != sizeof(QByteArrayData))
TRUEFALSE
yes
Evaluation Count:208172
yes
Evaluation Count:47
47-5544704
511 *this = ba; -
512 } else if (ba.d->size != 0) {
executed: }
Execution Count:208178
evaluated: ba.d->size != 0
TRUEFALSE
yes
Evaluation Count:5366786
yes
Evaluation Count:199449
199449-5366786
513 if (d->ref.isShared() || uint(d->size + ba.d->size) + 1u > d->alloc)
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:89346
yes
Evaluation Count:5277486
evaluated: uint(d->size + ba.d->size) + 1u > d->alloc
TRUEFALSE
yes
Evaluation Count:407197
yes
Evaluation Count:4870289
89346-5277486
514 reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::Grow);
Execution Count:496544
496544
515 memcpy(d->data() + d->size, ba.d->data(), ba.d->size); -
516 d->size += ba.d->size; -
517 d->data()[d->size] = '\0'; -
518 }
executed: }
Execution Count:5366799
5366799
519 return *this;
executed: return *this;
Execution Count:5774409
5774409
520} -
521QByteArray& QByteArray::append(const char *str) -
522{ -
523 if (str) {
evaluated: str
TRUEFALSE
yes
Evaluation Count:2701205
yes
Evaluation Count:9
9-2701205
524 const int len = int(strlen(str)); -
525 if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc)
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:82095
yes
Evaluation Count:2619110
evaluated: uint(d->size + len) + 1u > d->alloc
TRUEFALSE
yes
Evaluation Count:2792
yes
Evaluation Count:2616318
2792-2619110
526 reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
Execution Count:84887
84887
527 memcpy(d->data() + d->size, str, len + 1); -
528 d->size += len; -
529 }
executed: }
Execution Count:2701205
2701205
530 return *this;
executed: return *this;
Execution Count:2701214
2701214
531} -
532QByteArray &QByteArray::append(const char *str, int len) -
533{ -
534 if (len < 0)
partially evaluated: len < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:442116
0-442116
535 len = qstrlen(str);
never executed: len = qstrlen(str);
0
536 if (str && len) {
partially evaluated: str
TRUEFALSE
yes
Evaluation Count:442116
no
Evaluation Count:0
partially evaluated: len
TRUEFALSE
yes
Evaluation Count:442116
no
Evaluation Count:0
0-442116
537 if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc)
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:442005
yes
Evaluation Count:111
evaluated: uint(d->size + len) + 1u > d->alloc
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:103
8-442005
538 reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
Execution Count:442013
442013
539 memcpy(d->data() + d->size, str, len); -
540 d->size += len; -
541 d->data()[d->size] = '\0'; -
542 }
executed: }
Execution Count:442116
442116
543 return *this;
executed: return *this;
Execution Count:442116
442116
544} -
545 -
546 -
547 -
548 -
549 -
550 -
551 -
552QByteArray& QByteArray::append(char ch) -
553{ -
554 if (d->ref.isShared() || uint(d->size) + 2u > d->alloc)
evaluated: d->ref.isShared()
TRUEFALSE
yes
Evaluation Count:54361
yes
Evaluation Count:29725917
evaluated: uint(d->size) + 2u > d->alloc
TRUEFALSE
yes
Evaluation Count:92444
yes
Evaluation Count:29633550
54361-29725917
555 reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow);
executed: reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow);
Execution Count:146805
146805
556 d->data()[d->size++] = ch; -
557 d->data()[d->size] = '\0'; -
558 return *this;
executed: return *this;
Execution Count:29780233
29780233
559} -
560 -
561 -
562 -
563 -
564 -
565 -
566static inline QByteArray &qbytearray_insert(QByteArray *ba, -
567 int pos, const char *arr, int len) -
568{ -
569 qt_noop(); -
570 -
571 if (pos < 0 || len <= 0 || arr == 0)
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:119325
partially evaluated: len <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:119325
partially evaluated: arr == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:119325
0-119325
572 return *ba;
never executed: return *ba;
0
573 -
574 int oldsize = ba->size(); -
575 ba->resize(qMax(pos, oldsize) + len); -
576 char *dst = ba->data(); -
577 if (pos > oldsize)
evaluated: pos > oldsize
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:119323
2-119323
578 ::memset(dst + oldsize, 0x20, pos - oldsize);
executed: ::memset(dst + oldsize, 0x20, pos - oldsize);
Execution Count:2
2
579 else -
580 ::memmove(dst + pos + len, dst + pos, oldsize - pos);
executed: ::memmove(dst + pos + len, dst + pos, oldsize - pos);
Execution Count:119323
119323
581 memcpy(dst + pos, arr, len); -
582 return *ba;
executed: return *ba;
Execution Count:119325
119325
583} -
584QByteArray &QByteArray::insert(int i, const QByteArray &ba) -
585{ -
586 QByteArray copy(ba); -
587 return qbytearray_insert(this, i, copy.d->data(), copy.d->size);
executed: return qbytearray_insert(this, i, copy.d->data(), copy.d->size);
Execution Count:12
12
588} -
589QByteArray &QByteArray::insert(int i, const char *str) -
590{ -
591 return qbytearray_insert(this, i, str, qstrlen(str));
executed: return qbytearray_insert(this, i, str, qstrlen(str));
Execution Count:14
14
592} -
593QByteArray &QByteArray::insert(int i, const char *str, int len) -
594{ -
595 return qbytearray_insert(this, i, str, len);
executed: return qbytearray_insert(this, i, str, len);
Execution Count:1
1
596} -
597QByteArray &QByteArray::insert(int i, char ch) -
598{ -
599 return qbytearray_insert(this, i, &ch, 1);
executed: return qbytearray_insert(this, i, &ch, 1);
Execution Count:2356
2356
600} -
601QByteArray &QByteArray::remove(int pos, int len) -
602{ -
603 if (len <= 0 || pos >= d->size || pos < 0)
evaluated: len <= 0
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:263576
evaluated: pos >= d->size
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:263573
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:263573
0-263576
604 return *this;
executed: return *this;
Execution Count:66
66
605 detach(); -
606 if (pos + len >= d->size) {
evaluated: pos + len >= d->size
TRUEFALSE
yes
Evaluation Count:797
yes
Evaluation Count:262776
797-262776
607 resize(pos); -
608 } else {
executed: }
Execution Count:797
797
609 memmove(d->data() + pos, d->data() + pos + len, d->size - pos - len); -
610 resize(d->size - len); -
611 }
executed: }
Execution Count:262776
262776
612 return *this;
executed: return *this;
Execution Count:263573
263573
613} -
614QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after) -
615{ -
616 if (len == after.d->size && (pos + len <= d->size)) {
evaluated: len == after.d->size
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
evaluated: (pos + len <= d->size)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-8
617 detach(); -
618 memmove(d->data() + pos, after.d->data(), len*sizeof(char)); -
619 return *this;
executed: return *this;
Execution Count:2
2
620 } else { -
621 QByteArray copy(after); -
622 -
623 remove(pos, len); -
624 return insert(pos, copy);
executed: return insert(pos, copy);
Execution Count:9
9
625 } -
626} -
627QByteArray &QByteArray::replace(int pos, int len, const char *after) -
628{ -
629 return replace(pos,len,after,qstrlen(after));
executed: return replace(pos,len,after,qstrlen(after));
Execution Count:116943
116943
630} -
631QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) -
632{ -
633 if (len == alen && (pos + len <= d->size)) {
evaluated: len == alen
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:116941
evaluated: (pos + len <= d->size)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-116941
634 detach(); -
635 memcpy(d->data() + pos, after, len*sizeof(char)); -
636 return *this;
executed: return *this;
Execution Count:2
2
637 } else { -
638 remove(pos, len); -
639 return qbytearray_insert(this, pos, after, alen);
executed: return qbytearray_insert(this, pos, after, alen);
Execution Count:116942
116942
640 } -
641} -
642QByteArray &QByteArray::replace(const QByteArray &before, const QByteArray &after) -
643{ -
644 if (isNull() || before.d == after.d)
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: before.d == after.d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
645 return *this;
never executed: return *this;
0
646 -
647 QByteArray aft = after; -
648 if (after.d == d)
evaluated: after.d == d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
649 aft.detach();
executed: aft.detach();
Execution Count:2
2
650 -
651 return replace(before.constData(), before.size(), aft.constData(), aft.size());
executed: return replace(before.constData(), before.size(), aft.constData(), aft.size());
Execution Count:3
3
652} -
653QByteArray &QByteArray::replace(const char *c, const QByteArray &after) -
654{ -
655 QByteArray aft = after; -
656 if (after.d == d)
never evaluated: after.d == d
0
657 aft.detach();
never executed: aft.detach();
0
658 -
659 return replace(c, qstrlen(c), aft.constData(), aft.size());
never executed: return replace(c, qstrlen(c), aft.constData(), aft.size());
0
660} -
661QByteArray &QByteArray::replace(const char *before, int bsize, const char *after, int asize) -
662{ -
663 if (isNull() || (before == after && bsize == asize))
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:1778
partially evaluated: before == after
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1778
never evaluated: bsize == asize
0-1778
664 return *this;
executed: return *this;
Execution Count:21
21
665 -
666 -
667 const char *a = after; -
668 const char *b = before; -
669 if (after >= d->data() && after < d->data() + d->size) {
evaluated: after >= d->data()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1777
partially evaluated: after < d->data() + d->size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1777
670 char *copy = (char *)malloc(asize); -
671 do { if (!(copy)) qBadAlloc(); } while (0);
never executed: qBadAlloc();
never executed: }
never evaluated: !(copy)
never evaluated: 0
0
672 memcpy(copy, after, asize); -
673 a = copy; -
674 }
never executed: }
0
675 if (before >= d->data() && before < d->data() + d->size) {
partially evaluated: before >= d->data()
TRUEFALSE
yes
Evaluation Count:1778
no
Evaluation Count:0
evaluated: before < d->data() + d->size
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1776
0-1778
676 char *copy = (char *)malloc(bsize); -
677 do { if (!(copy)) qBadAlloc(); } while (0);
never executed: qBadAlloc();
executed: }
Execution Count:2
partially evaluated: !(copy)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
678 memcpy(copy, before, bsize); -
679 b = copy; -
680 }
executed: }
Execution Count:2
2
681 -
682 QByteArrayMatcher matcher(before, bsize); -
683 int index = 0; -
684 int len = d->size; -
685 char *d = data(); -
686 -
687 if (bsize == asize) {
evaluated: bsize == asize
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1777
1-1777
688 if (bsize) {
partially evaluated: bsize
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
689 while ((index = matcher.indexIn(*this, index)) != -1) {
evaluated: (index = matcher.indexIn(*this, index)) != -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
690 memcpy(d + index, after, asize); -
691 index += bsize; -
692 }
executed: }
Execution Count:1
1
693 }
executed: }
Execution Count:1
1
694 } else if (asize < bsize) {
executed: }
Execution Count:1
evaluated: asize < bsize
TRUEFALSE
yes
Evaluation Count:1775
yes
Evaluation Count:2
1-1775
695 uint to = 0; -
696 uint movestart = 0; -
697 uint num = 0; -
698 while ((index = matcher.indexIn(*this, index)) != -1) {
evaluated: (index = matcher.indexIn(*this, index)) != -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1775
1-1775
699 if (num) {
partially evaluated: num
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
700 int msize = index - movestart; -
701 if (msize > 0) {
never evaluated: msize > 0
0
702 memmove(d + to, d + movestart, msize); -
703 to += msize; -
704 }
never executed: }
0
705 } else {
never executed: }
0
706 to = index; -
707 }
executed: }
Execution Count:1
1
708 if (asize) {
partially evaluated: asize
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
709 memcpy(d + to, after, asize); -
710 to += asize; -
711 }
executed: }
Execution Count:1
1
712 index += bsize; -
713 movestart = index; -
714 num++; -
715 }
executed: }
Execution Count:1
1
716 if (num) {
evaluated: num
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1774
1-1774
717 int msize = len - movestart; -
718 if (msize > 0)
partially evaluated: msize > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
719 memmove(d + to, d + movestart, msize);
never executed: memmove(d + to, d + movestart, msize);
0
720 resize(len - num*(bsize-asize)); -
721 }
executed: }
Execution Count:1
1
722 } else {
executed: }
Execution Count:1775
1775
723 -
724 -
725 while (index != -1) {
evaluated: index != -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
726 uint indices[4096]; -
727 uint pos = 0; -
728 while(pos < 4095) {
partially evaluated: pos < 4095
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
729 index = matcher.indexIn(*this, index); -
730 if (index == -1)
evaluated: index == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
731 break;
executed: break;
Execution Count:2
2
732 indices[pos++] = index; -
733 index += bsize; -
734 -
735 if (!bsize)
partially evaluated: !bsize
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
736 index++;
never executed: index++;
0
737 }
executed: }
Execution Count:6
6
738 if (!pos)
partially evaluated: !pos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
739 break;
never executed: break;
0
740 -
741 -
742 int adjust = pos*(asize-bsize); -
743 -
744 if (index != -1)
partially evaluated: index != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
745 index += adjust;
never executed: index += adjust;
0
746 int newlen = len + adjust; -
747 int moveend = len; -
748 if (newlen > len) {
partially evaluated: newlen > len
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
749 resize(newlen); -
750 len = newlen; -
751 }
executed: }
Execution Count:2
2
752 d = this->d->data(); -
753 -
754 while(pos) {
evaluated: pos
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
755 pos--; -
756 int movestart = indices[pos] + bsize; -
757 int insertstart = indices[pos] + pos*(asize-bsize); -
758 int moveto = insertstart + asize; -
759 memmove(d + moveto, d + movestart, (moveend - movestart)); -
760 if (asize)
partially evaluated: asize
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
761 memcpy(d + insertstart, after, asize);
executed: memcpy(d + insertstart, after, asize);
Execution Count:6
6
762 moveend = movestart - bsize; -
763 }
executed: }
Execution Count:6
6
764 }
executed: }
Execution Count:2
2
765 }
executed: }
Execution Count:2
2
766 -
767 if (a != after)
partially evaluated: a != after
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1778
0-1778
768 ::free((char *)a);
never executed: ::free((char *)a);
0
769 if (b != before)
evaluated: b != before
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1776
2-1776
770 ::free((char *)b);
executed: ::free((char *)b);
Execution Count:2
2
771 -
772 -
773 return *this;
executed: return *this;
Execution Count:1778
1778
774} -
775QByteArray &QByteArray::replace(char before, const QByteArray &after) -
776{ -
777 char b[2] = { before, '\0' }; -
778 QByteArray cb = fromRawData(b, 1); -
779 return replace(cb, after);
executed: return replace(cb, after);
Execution Count:2
2
780} -
781QByteArray &QByteArray::replace(char before, char after) -
782{ -
783 if (d->size) {
partially evaluated: d->size
TRUEFALSE
yes
Evaluation Count:15990379
no
Evaluation Count:0
0-15990379
784 char *i = data(); -
785 char *e = i + d->size; -
786 for (; i != e; ++i)
evaluated: i != e
TRUEFALSE
yes
Evaluation Count:18150180
yes
Evaluation Count:15990380
15990380-18150180
787 if (*i == before)
evaluated: *i == before
TRUEFALSE
yes
Evaluation Count:1036
yes
Evaluation Count:18149145
1036-18149145
788 * i = after;
executed: * i = after;
Execution Count:1036
1036
789 }
executed: }
Execution Count:15990382
15990382
790 return *this;
executed: return *this;
Execution Count:15990382
15990382
791} -
792QList<QByteArray> QByteArray::split(char sep) const -
793{ -
794 QList<QByteArray> list; -
795 int start = 0; -
796 int end; -
797 while ((end = indexOf(sep, start)) != -1) {
evaluated: (end = indexOf(sep, start)) != -1
TRUEFALSE
yes
Evaluation Count:588570
yes
Evaluation Count:225525
225525-588570
798 list.append(mid(start, end - start)); -
799 start = end + 1; -
800 }
executed: }
Execution Count:588570
588570
801 list.append(mid(start)); -
802 return list;
executed: return list;
Execution Count:225525
225525
803} -
804QByteArray QByteArray::repeated(int times) const -
805{ -
806 if (d->size == 0)
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:11
5-11
807 return *this;
executed: return *this;
Execution Count:5
5
808 -
809 if (times <= 1) {
evaluated: times <= 1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7
4-7
810 if (times == 1)
evaluated: times == 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
811 return *this;
executed: return *this;
Execution Count:1
1
812 return QByteArray();
executed: return QByteArray();
Execution Count:3
3
813 } -
814 -
815 const int resultSize = times * d->size; -
816 -
817 QByteArray result; -
818 result.reserve(resultSize); -
819 if (result.d->alloc != uint(resultSize) + 1u)
partially evaluated: result.d->alloc != uint(resultSize) + 1u
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
820 return QByteArray();
never executed: return QByteArray();
0
821 -
822 memcpy(result.d->data(), d->data(), d->size); -
823 -
824 int sizeSoFar = d->size; -
825 char *end = result.d->data() + sizeSoFar; -
826 -
827 const int halfResultSize = resultSize >> 1; -
828 while (sizeSoFar <= halfResultSize) {
evaluated: sizeSoFar <= halfResultSize
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
7-12
829 memcpy(end, result.d->data(), sizeSoFar); -
830 end += sizeSoFar; -
831 sizeSoFar <<= 1; -
832 }
executed: }
Execution Count:12
12
833 memcpy(end, result.d->data(), resultSize - sizeSoFar); -
834 result.d->data()[resultSize] = '\0'; -
835 result.d->size = resultSize; -
836 return result;
executed: return result;
Execution Count:7
7
837} -
838int QByteArray::indexOf(const QByteArray &ba, int from) const -
839{ -
840 const int ol = ba.d->size; -
841 if (ol == 0)
evaluated: ol == 0
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1878
16-1878
842 return from;
executed: return from;
Execution Count:16
16
843 if (ol == 1)
evaluated: ol == 1
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:1806
72-1806
844 return indexOf(*ba.d->data(), from);
executed: return indexOf(*ba.d->data(), from);
Execution Count:72
72
845 -
846 const int l = d->size; -
847 if (from > d->size || ol + from > l)
partially evaluated: from > d->size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1806
evaluated: ol + from > l
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1796
0-1806
848 return -1;
executed: return -1;
Execution Count:10
10
849 -
850 return qFindByteArray(d->data(), d->size, from, ba.d->data(), ol);
executed: return qFindByteArray(d->data(), d->size, from, ba.d->data(), ol);
Execution Count:1796
1796
851} -
852int QByteArray::indexOf(const char *c, int from) const -
853{ -
854 const int ol = qstrlen(c); -
855 if (ol == 1)
evaluated: ol == 1
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:678884
24-678884
856 return indexOf(*c, from);
executed: return indexOf(*c, from);
Execution Count:24
24
857 -
858 const int l = d->size; -
859 if (from > d->size || ol + from > l)
partially evaluated: from > d->size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:678884
evaluated: ol + from > l
TRUEFALSE
yes
Evaluation Count:6052
yes
Evaluation Count:672832
0-678884
860 return -1;
executed: return -1;
Execution Count:6052
6052
861 if (ol == 0)
evaluated: ol == 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:672824
8-672824
862 return from;
executed: return from;
Execution Count:8
8
863 -
864 return qFindByteArray(d->data(), d->size, from, c, ol);
executed: return qFindByteArray(d->data(), d->size, from, c, ol);
Execution Count:672824
672824
865} -
866int QByteArray::indexOf(char ch, int from) const -
867{ -
868 if (from < 0)
evaluated: from < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:955461
1-955461
869 from = qMax(from + d->size, 0);
executed: from = qMax(from + d->size, 0);
Execution Count:1
1
870 if (from < d->size) {
evaluated: from < d->size
TRUEFALSE
yes
Evaluation Count:953182
yes
Evaluation Count:2280
2280-953182
871 const char *n = d->data() + from - 1; -
872 const char *e = d->data() + d->size; -
873 while (++n != e)
evaluated: ++n != e
TRUEFALSE
yes
Evaluation Count:15462496
yes
Evaluation Count:224664
224664-15462496
874 if (*n == ch)
evaluated: *n == ch
TRUEFALSE
yes
Evaluation Count:728518
yes
Evaluation Count:14733978
728518-14733978
875 return n - d->data();
executed: return n - d->data();
Execution Count:728518
728518
876 }
executed: }
Execution Count:224664
224664
877 return -1;
executed: return -1;
Execution Count:226944
226944
878} -
879 -
880 -
881static int lastIndexOfHelper(const char *haystack, int l, const char *needle, int ol, int from) -
882{ -
883 int delta = l - ol; -
884 if (from < 0)
evaluated: from < 0
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:20
20-40
885 from = delta;
executed: from = delta;
Execution Count:40
40
886 if (from < 0 || from > l)
evaluated: from < 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:55
partially evaluated: from > l
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
0-55
887 return -1;
executed: return -1;
Execution Count:5
5
888 if (from > delta)
evaluated: from > delta
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:53
2-53
889 from = delta;
executed: from = delta;
Execution Count:2
2
890 -
891 const char *end = haystack; -
892 haystack += from; -
893 const uint ol_minus_1 = ol - 1; -
894 const char *n = needle + ol_minus_1; -
895 const char *h = haystack + ol_minus_1; -
896 uint hashNeedle = 0, hashHaystack = 0; -
897 int idx; -
898 for (idx = 0; idx < ol; ++idx) {
evaluated: idx < ol
TRUEFALSE
yes
Evaluation Count:310
yes
Evaluation Count:55
55-310
899 hashNeedle = ((hashNeedle<<1) + *(n-idx)); -
900 hashHaystack = ((hashHaystack<<1) + *(h-idx)); -
901 }
executed: }
Execution Count:310
310
902 hashHaystack -= *haystack; -
903 while (haystack >= end) {
evaluated: haystack >= end
TRUEFALSE
yes
Evaluation Count:285
yes
Evaluation Count:14
14-285
904 hashHaystack += *haystack; -
905 if (hashHaystack == hashNeedle && memcmp(needle, haystack, ol) == 0)
evaluated: hashHaystack == hashNeedle
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:242
evaluated: memcmp(needle, haystack, ol) == 0
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:2
2-242
906 return haystack - end;
executed: return haystack - end;
Execution Count:41
41
907 --haystack; -
908 if (ol_minus_1 < sizeof(uint) * 8) hashHaystack -= (*(haystack + ol)) << ol_minus_1; hashHaystack <<= 1;
executed: hashHaystack -= (*(haystack + ol)) << ol_minus_1;
Execution Count:210
evaluated: ol_minus_1 < sizeof(uint) * 8
TRUEFALSE
yes
Evaluation Count:210
yes
Evaluation Count:34
34-210
909 }
executed: }
Execution Count:244
244
910 return -1;
executed: return -1;
Execution Count:14
14
911 -
912} -
913int QByteArray::lastIndexOf(const QByteArray &ba, int from) const -
914{ -
915 const int ol = ba.d->size; -
916 if (ol == 1)
evaluated: ol == 1
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:36
34-36
917 return lastIndexOf(*ba.d->data(), from);
executed: return lastIndexOf(*ba.d->data(), from);
Execution Count:34
34
918 -
919 return lastIndexOfHelper(d->data(), d->size, ba.d->data(), ol, from);
executed: return lastIndexOfHelper(d->data(), d->size, ba.d->data(), ol, from);
Execution Count:36
36
920} -
921int QByteArray::lastIndexOf(const char *str, int from) const -
922{ -
923 const int ol = qstrlen(str); -
924 if (ol == 1)
evaluated: ol == 1
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:24
24
925 return lastIndexOf(*str, from);
executed: return lastIndexOf(*str, from);
Execution Count:24
24
926 -
927 return lastIndexOfHelper(d->data(), d->size, str, ol, from);
executed: return lastIndexOfHelper(d->data(), d->size, str, ol, from);
Execution Count:24
24
928} -
929int QByteArray::lastIndexOf(char ch, int from) const -
930{ -
931 if (from < 0)
evaluated: from < 0
TRUEFALSE
yes
Evaluation Count:150
yes
Evaluation Count:42
42-150
932 from += d->size;
executed: from += d->size;
Execution Count:150
150
933 else if (from > d->size)
partially evaluated: from > d->size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
934 from = d->size-1;
never executed: from = d->size-1;
0
935 if (from >= 0) {
evaluated: from >= 0
TRUEFALSE
yes
Evaluation Count:178
yes
Evaluation Count:14
14-178
936 const char *b = d->data(); -
937 const char *n = d->data() + from + 1; -
938 while (n-- != b)
evaluated: n-- != b
TRUEFALSE
yes
Evaluation Count:383
yes
Evaluation Count:33
33-383
939 if (*n == ch)
evaluated: *n == ch
TRUEFALSE
yes
Evaluation Count:145
yes
Evaluation Count:238
145-238
940 return n - b;
executed: return n - b;
Execution Count:145
145
941 }
executed: }
Execution Count:33
33
942 return -1;
executed: return -1;
Execution Count:47
47
943} -
944int QByteArray::count(const QByteArray &ba) const -
945{ -
946 int num = 0; -
947 int i = -1; -
948 if (d->size > 500 && ba.d->size > 5) {
partially evaluated: d->size > 500
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: ba.d->size > 5
0-4
949 QByteArrayMatcher matcher(ba); -
950 while ((i = matcher.indexIn(*this, i + 1)) != -1)
never evaluated: (i = matcher.indexIn(*this, i + 1)) != -1
0
951 ++num;
never executed: ++num;
0
952 } else {
never executed: }
0
953 while ((i = indexOf(ba, i + 1)) != -1)
evaluated: (i = indexOf(ba, i + 1)) != -1
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:4
4-33
954 ++num;
executed: ++num;
Execution Count:33
33
955 }
executed: }
Execution Count:4
4
956 return num;
executed: return num;
Execution Count:4
4
957} -
958int QByteArray::count(const char *str) const -
959{ -
960 return count(fromRawData(str, qstrlen(str)));
executed: return count(fromRawData(str, qstrlen(str)));
Execution Count:4
4
961} -
962int QByteArray::count(char ch) const -
963{ -
964 int num = 0; -
965 const char *i = d->data() + d->size; -
966 const char *b = d->data(); -
967 while (i != b)
evaluated: i != b
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:4
4-80
968 if (*--i == ch)
evaluated: *--i == ch
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:57
23-57
969 ++num;
executed: ++num;
Execution Count:23
23
970 return num;
executed: return num;
Execution Count:4
4
971} -
972bool QByteArray::startsWith(const QByteArray &ba) const -
973{ -
974 if (d == ba.d || ba.d->size == 0)
evaluated: d == ba.d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:57
evaluated: ba.d->size == 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:53
2-57
975 return true;
executed: return true;
Execution Count:6
6
976 if (d->size < ba.d->size)
evaluated: d->size < ba.d->size
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:42
11-42
977 return false;
executed: return false;
Execution Count:11
11
978 return memcmp(d->data(), ba.d->data(), ba.d->size) == 0;
executed: return memcmp(d->data(), ba.d->data(), ba.d->size) == 0;
Execution Count:42
42
979} -
980 -
981 -
982 -
983 -
984 -
985 -
986bool QByteArray::startsWith(const char *str) const -
987{ -
988 if (!str || !*str)
evaluated: !str
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:508052
evaluated: !*str
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:508049
3-508052
989 return true;
executed: return true;
Execution Count:6
6
990 const int len = int(strlen(str)); -
991 if (d->size < len)
evaluated: d->size < len
TRUEFALSE
yes
Evaluation Count:43047
yes
Evaluation Count:465002
43047-465002
992 return false;
executed: return false;
Execution Count:43047
43047
993 return qstrncmp(d->data(), str, len) == 0;
executed: return qstrncmp(d->data(), str, len) == 0;
Execution Count:465002
465002
994} -
995 -
996 -
997 -
998 -
999 -
1000 -
1001bool QByteArray::startsWith(char ch) const -
1002{ -
1003 if (d->size == 0)
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:101625
51-101625
1004 return false;
executed: return false;
Execution Count:51
51
1005 return d->data()[0] == ch;
executed: return d->data()[0] == ch;
Execution Count:101626
101626
1006} -
1007bool QByteArray::endsWith(const QByteArray &ba) const -
1008{ -
1009 if (d == ba.d || ba.d->size == 0)
evaluated: d == ba.d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
evaluated: ba.d->size == 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
2-9
1010 return true;
executed: return true;
Execution Count:6
6
1011 if (d->size < ba.d->size)
evaluated: d->size < ba.d->size
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
1012 return false;
executed: return false;
Execution Count:3
3
1013 return memcmp(d->data() + d->size - ba.d->size, ba.d->data(), ba.d->size) == 0;
executed: return memcmp(d->data() + d->size - ba.d->size, ba.d->data(), ba.d->size) == 0;
Execution Count:2
2
1014} -
1015 -
1016 -
1017 -
1018 -
1019 -
1020 -
1021bool QByteArray::endsWith(const char *str) const -
1022{ -
1023 if (!str || !*str)
evaluated: !str
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:185628
evaluated: !*str
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:185625
3-185628
1024 return true;
executed: return true;
Execution Count:6
6
1025 const int len = int(strlen(str)); -
1026 if (d->size < len)
evaluated: d->size < len
TRUEFALSE
yes
Evaluation Count:48156
yes
Evaluation Count:137469
48156-137469
1027 return false;
executed: return false;
Execution Count:48156
48156
1028 return qstrncmp(d->data() + d->size - len, str, len) == 0;
executed: return qstrncmp(d->data() + d->size - len, str, len) == 0;
Execution Count:137469
137469
1029} -
1030 -
1031 -
1032 -
1033 -
1034 -
1035 -
1036bool QByteArray::endsWith(char ch) const -
1037{ -
1038 if (d->size == 0)
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:36206
45-36206
1039 return false;
executed: return false;
Execution Count:45
45
1040 return d->data()[d->size - 1] == ch;
executed: return d->data()[d->size - 1] == ch;
Execution Count:36206
36206
1041} -
1042QByteArray QByteArray::left(int len) const -
1043{ -
1044 if (len >= d->size)
evaluated: len >= d->size
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:131588
77-131588
1045 return *this;
executed: return *this;
Execution Count:77
77
1046 if (len < 0)
partially evaluated: len < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131588
0-131588
1047 len = 0;
never executed: len = 0;
0
1048 return QByteArray(d->data(), len);
executed: return QByteArray(d->data(), len);
Execution Count:131588
131588
1049} -
1050QByteArray QByteArray::right(int len) const -
1051{ -
1052 if (len >= d->size)
evaluated: len >= d->size
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:14
4-14
1053 return *this;
executed: return *this;
Execution Count:4
4
1054 if (len < 0)
partially evaluated: len < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
1055 len = 0;
never executed: len = 0;
0
1056 return QByteArray(d->data() + d->size - len, len);
executed: return QByteArray(d->data() + d->size - len, len);
Execution Count:14
14
1057} -
1058QByteArray QByteArray::mid(int pos, int len) const -
1059{ -
1060 if ((d->size == 0 && d->ref.isStatic()) || pos > d->size)
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:308
yes
Evaluation Count:949898
partially evaluated: d->ref.isStatic()
TRUEFALSE
yes
Evaluation Count:308
no
Evaluation Count:0
partially evaluated: pos > d->size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:949898
0-949898
1061 return QByteArray();
executed: return QByteArray();
Execution Count:308
308
1062 if (len < 0)
evaluated: len < 0
TRUEFALSE
yes
Evaluation Count:338342
yes
Evaluation Count:611556
338342-611556
1063 len = d->size - pos;
executed: len = d->size - pos;
Execution Count:338342
338342
1064 if (pos < 0) {
evaluated: pos < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:949897
1-949897
1065 len += pos; -
1066 pos = 0; -
1067 }
executed: }
Execution Count:1
1
1068 if (len + pos > d->size)
evaluated: len + pos > d->size
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:949894
4-949894
1069 len = d->size - pos;
executed: len = d->size - pos;
Execution Count:4
4
1070 if (pos == 0 && len == d->size)
evaluated: pos == 0
TRUEFALSE
yes
Evaluation Count:227429
yes
Evaluation Count:722469
evaluated: len == d->size
TRUEFALSE
yes
Evaluation Count:58584
yes
Evaluation Count:168845
58584-722469
1071 return *this;
executed: return *this;
Execution Count:58584
58584
1072 return QByteArray(d->data() + pos, len);
executed: return QByteArray(d->data() + pos, len);
Execution Count:891314
891314
1073} -
1074QByteArray QByteArray::toLower() const -
1075{ -
1076 QByteArray s(*this); -
1077 register uchar *p = reinterpret_cast<uchar *>(s.data()); -
1078 if (p) {
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:124573
no
Evaluation Count:0
0-124573
1079 while (*p) {
evaluated: *p
TRUEFALSE
yes
Evaluation Count:1110653
yes
Evaluation Count:124573
124573-1110653
1080 *p = QChar::toLower((ushort)*p); -
1081 p++; -
1082 }
executed: }
Execution Count:1110653
1110653
1083 }
executed: }
Execution Count:124573
124573
1084 return s;
executed: return s;
Execution Count:124573
124573
1085} -
1086QByteArray QByteArray::toUpper() const -
1087{ -
1088 QByteArray s(*this); -
1089 register uchar *p = reinterpret_cast<uchar *>(s.data()); -
1090 if (p) {
partially evaluated: p
TRUEFALSE
yes
Evaluation Count:189
no
Evaluation Count:0
0-189
1091 while (*p) {
evaluated: *p
TRUEFALSE
yes
Evaluation Count:675
yes
Evaluation Count:189
189-675
1092 *p = QChar::toUpper((ushort)*p); -
1093 p++; -
1094 }
executed: }
Execution Count:675
675
1095 }
executed: }
Execution Count:189
189
1096 return s;
executed: return s;
Execution Count:189
189
1097} -
1098void QByteArray::clear() -
1099{ -
1100 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:5905
yes
Evaluation Count:621701
5905-621701
1101 Data::deallocate(d);
executed: Data::deallocate(d);
Execution Count:5905
5905
1102 d = Data::sharedNull(); -
1103}
executed: }
Execution Count:627606
627606
1104QDataStream &operator<<(QDataStream &out, const QByteArray &ba) -
1105{ -
1106 if (ba.isNull() && out.version() >= 6) {
evaluated: ba.isNull()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1548
partially evaluated: out.version() >= 6
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
0-1548
1107 out << (quint32)0xffffffff; -
1108 return out;
executed: return out;
Execution Count:19
19
1109 } -
1110 return out.writeBytes(ba.constData(), ba.size());
executed: return out.writeBytes(ba.constData(), ba.size());
Execution Count:1548
1548
1111} -
1112QDataStream &operator>>(QDataStream &in, QByteArray &ba) -
1113{ -
1114 ba.clear(); -
1115 quint32 len; -
1116 in >> len; -
1117 if (len == 0xffffffff)
evaluated: len == 0xffffffff
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1329
24-1329
1118 return in;
executed: return in;
Execution Count:24
24
1119 -
1120 const quint32 Step = 1024 * 1024; -
1121 quint32 allocated = 0; -
1122 -
1123 do { -
1124 int blockSize = qMin(Step, len - allocated); -
1125 ba.resize(allocated + blockSize); -
1126 if (in.readRawData(ba.data() + allocated, blockSize) != blockSize) {
evaluated: in.readRawData(ba.data() + allocated, blockSize) != blockSize
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1332
11-1332
1127 ba.clear(); -
1128 in.setStatus(QDataStream::ReadPastEnd); -
1129 return in;
executed: return in;
Execution Count:11
11
1130 } -
1131 allocated += blockSize; -
1132 } while (allocated < len);
executed: }
Execution Count:1332
evaluated: allocated < len
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:1318
14-1332
1133 -
1134 return in;
executed: return in;
Execution Count:1318
1318
1135} -
1136QByteArray QByteArray::simplified() const -
1137{ -
1138 if (d->size == 0)
partially evaluated: d->size == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112388
0-112388
1139 return *this;
never executed: return *this;
0
1140 QByteArray result(d->size, Qt::Uninitialized); -
1141 const char *from = d->data(); -
1142 const char *fromend = from + d->size; -
1143 int outc=0; -
1144 char *to = result.d->data(); -
1145 for (;;) { -
1146 while (from!=fromend && isspace(uchar(*from)))
evaluated: from!=fromend
TRUEFALSE
yes
Evaluation Count:457095
yes
Evaluation Count:228
evaluated: isspace(uchar(*from))
TRUEFALSE
yes
Evaluation Count:230624
yes
Evaluation Count:226471
228-457095
1147 from++;
executed: from++;
Execution Count:230624
230624
1148 while (from!=fromend && !isspace(uchar(*from)))
evaluated: from!=fromend
TRUEFALSE
yes
Evaluation Count:999970
yes
Evaluation Count:112388
evaluated: !isspace(uchar(*from))
TRUEFALSE
yes
Evaluation Count:885659
yes
Evaluation Count:114311
112388-999970
1149 to[outc++] = *from++;
executed: to[outc++] = *from++;
Execution Count:885659
885659
1150 if (from!=fromend)
evaluated: from!=fromend
TRUEFALSE
yes
Evaluation Count:114311
yes
Evaluation Count:112388
112388-114311
1151 to[outc++] = ' ';
executed: to[outc++] = ' ';
Execution Count:114311
114311
1152 else -
1153 break;
executed: break;
Execution Count:112388
112388
1154 } -
1155 if (outc > 0 && to[outc-1] == ' ')
partially evaluated: outc > 0
TRUEFALSE
yes
Evaluation Count:112388
no
Evaluation Count:0
evaluated: to[outc-1] == ' '
TRUEFALSE
yes
Evaluation Count:228
yes
Evaluation Count:112160
0-112388
1156 outc--;
executed: outc--;
Execution Count:228
228
1157 result.resize(outc); -
1158 return result;
executed: return result;
Execution Count:112388
112388
1159} -
1160QByteArray QByteArray::trimmed() const -
1161{ -
1162 if (d->size == 0)
evaluated: d->size == 0
TRUEFALSE
yes
Evaluation Count:103
yes
Evaluation Count:147023
103-147023
1163 return *this;
executed: return *this;
Execution Count:103
103
1164 const char *s = d->data(); -
1165 if (!isspace(uchar(*s)) && !isspace(uchar(s[d->size-1])))
evaluated: !isspace(uchar(*s))
TRUEFALSE
yes
Evaluation Count:141427
yes
Evaluation Count:5596
evaluated: !isspace(uchar(s[d->size-1]))
TRUEFALSE
yes
Evaluation Count:122835
yes
Evaluation Count:18592
5596-141427
1166 return *this;
executed: return *this;
Execution Count:122835
122835
1167 int start = 0; -
1168 int end = d->size - 1; -
1169 while (start<=end && isspace(uchar(s[start])))
evaluated: start<=end
TRUEFALSE
yes
Evaluation Count:29815
yes
Evaluation Count:6
evaluated: isspace(uchar(s[start]))
TRUEFALSE
yes
Evaluation Count:5633
yes
Evaluation Count:24182
6-29815
1170 start++;
executed: start++;
Execution Count:5633
5633
1171 if (start <= end) {
evaluated: start <= end
TRUEFALSE
yes
Evaluation Count:24182
yes
Evaluation Count:6
6-24182
1172 while (end && isspace(uchar(s[end])))
evaluated: end
TRUEFALSE
yes
Evaluation Count:42814
yes
Evaluation Count:35
evaluated: isspace(uchar(s[end]))
TRUEFALSE
yes
Evaluation Count:18667
yes
Evaluation Count:24147
35-42814
1173 end--;
executed: end--;
Execution Count:18667
18667
1174 }
executed: }
Execution Count:24182
24182
1175 int l = end - start + 1; -
1176 if (l <= 0) {
evaluated: l <= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:24182
6-24182
1177 QByteArrayDataPtr empty = { reinterpret_cast<QByteArrayData *>(Data::allocate(0)) }; -
1178 return QByteArray(empty);
executed: return QByteArray(empty);
Execution Count:6
6
1179 } -
1180 return QByteArray(s+start, l);
executed: return QByteArray(s+start, l);
Execution Count:24182
24182
1181} -
1182QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const -
1183{ -
1184 QByteArray result; -
1185 int len = d->size; -
1186 int padlen = width - len; -
1187 if (padlen > 0) {
evaluated: padlen > 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:8
5-8
1188 result.resize(len+padlen); -
1189 if (len)
evaluated: len
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1190 memcpy(result.d->data(), d->data(), len);
executed: memcpy(result.d->data(), d->data(), len);
Execution Count:4
4
1191 memset(result.d->data()+len, fill, padlen); -
1192 } else {
executed: }
Execution Count:5
5
1193 if (truncate)
evaluated: truncate
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
1194 result = left(width);
executed: result = left(width);
Execution Count:4
4
1195 else -
1196 result = *this;
executed: result = *this;
Execution Count:4
4
1197 } -
1198 return result;
executed: return result;
Execution Count:13
13
1199} -
1200QByteArray QByteArray::rightJustified(int width, char fill, bool truncate) const -
1201{ -
1202 QByteArray result; -
1203 int len = d->size; -
1204 int padlen = width - len; -
1205 if (padlen > 0) {
evaluated: padlen > 0
TRUEFALSE
yes
Evaluation Count:191
yes
Evaluation Count:678
191-678
1206 result.resize(len+padlen); -
1207 if (len)
evaluated: len
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:1
1-190
1208 memcpy(result.d->data()+padlen, data(), len);
executed: memcpy(result.d->data()+padlen, data(), len);
Execution Count:190
190
1209 memset(result.d->data(), fill, padlen); -
1210 } else {
executed: }
Execution Count:191
191
1211 if (truncate)
evaluated: truncate
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:674
4-674
1212 result = left(width);
executed: result = left(width);
Execution Count:4
4
1213 else -
1214 result = *this;
executed: result = *this;
Execution Count:674
674
1215 } -
1216 return result;
executed: return result;
Execution Count:869
869
1217} -
1218 -
1219bool QByteArray::isNull() const { return d == QArrayData::sharedNull(); }
executed: return d == QArrayData::sharedNull();
Execution Count:12685
12685
1220qlonglong QByteArray::toLongLong(bool *ok, int base) const -
1221{ -
1222 -
1223 -
1224 -
1225 -
1226 -
1227 -
1228 -
1229 return QLocalePrivate::bytearrayToLongLong(nulTerminated().constData(), base, ok);
executed: return QLocalePrivate::bytearrayToLongLong(nulTerminated().constData(), base, ok);
Execution Count:180620
180620
1230} -
1231qulonglong QByteArray::toULongLong(bool *ok, int base) const -
1232{ -
1233 -
1234 -
1235 -
1236 -
1237 -
1238 -
1239 -
1240 return QLocalePrivate::bytearrayToUnsLongLong(nulTerminated().constData(), base, ok);
executed: return QLocalePrivate::bytearrayToUnsLongLong(nulTerminated().constData(), base, ok);
Execution Count:3506
3506
1241} -
1242int QByteArray::toInt(bool *ok, int base) const -
1243{ -
1244 qlonglong v = toLongLong(ok, base); -
1245 if (v < (-2147483647 - 1) || v > 2147483647) {
partially evaluated: v < (-2147483647 - 1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:179820
evaluated: v > 2147483647
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:179724
0-179820
1246 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:96
no
Evaluation Count:0
0-96
1247 *ok = false;
executed: *ok = false;
Execution Count:96
96
1248 v = 0; -
1249 }
executed: }
Execution Count:96
96
1250 return int(v);
executed: return int(v);
Execution Count:179820
179820
1251} -
1252uint QByteArray::toUInt(bool *ok, int base) const -
1253{ -
1254 qulonglong v = toULongLong(ok, base); -
1255 if (v > (2147483647 * 2U + 1U)) {
never evaluated: v > (2147483647 * 2U + 1U)
0
1256 if (ok)
never evaluated: ok
0
1257 *ok = false;
never executed: *ok = false;
0
1258 v = 0; -
1259 }
never executed: }
0
1260 return uint(v);
never executed: return uint(v);
0
1261} -
1262long QByteArray::toLong(bool *ok, int base) const -
1263{ -
1264 qlonglong v = toLongLong(ok, base); -
1265 if (v < (-9223372036854775807L - 1L) || v > 9223372036854775807L) {
partially evaluated: v < (-9223372036854775807L - 1L)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:238
partially evaluated: v > 9223372036854775807L
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:238
0-238
1266 if (ok)
never evaluated: ok
0
1267 *ok = false;
never executed: *ok = false;
0
1268 v = 0; -
1269 }
never executed: }
0
1270 return long(v);
executed: return long(v);
Execution Count:238
238
1271} -
1272ulong QByteArray::toULong(bool *ok, int base) const -
1273{ -
1274 qulonglong v = toULongLong(ok, base); -
1275 if (v > (9223372036854775807L * 2UL + 1UL)) {
partially evaluated: v > (9223372036854775807L * 2UL + 1UL)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1276 if (ok)
never evaluated: ok
0
1277 *ok = false;
never executed: *ok = false;
0
1278 v = 0; -
1279 }
never executed: }
0
1280 return ulong(v);
executed: return ulong(v);
Execution Count:10
10
1281} -
1282short QByteArray::toShort(bool *ok, int base) const -
1283{ -
1284 qlonglong v = toLongLong(ok, base); -
1285 if (v < (-32767 - 1) || v > 32767) {
never evaluated: v < (-32767 - 1)
never evaluated: v > 32767
0
1286 if (ok)
never evaluated: ok
0
1287 *ok = false;
never executed: *ok = false;
0
1288 v = 0; -
1289 }
never executed: }
0
1290 return short(v);
never executed: return short(v);
0
1291} -
1292ushort QByteArray::toUShort(bool *ok, int base) const -
1293{ -
1294 qulonglong v = toULongLong(ok, base); -
1295 if (v > (32767 * 2 + 1)) {
never evaluated: v > (32767 * 2 + 1)
0
1296 if (ok)
never evaluated: ok
0
1297 *ok = false;
never executed: *ok = false;
0
1298 v = 0; -
1299 }
never executed: }
0
1300 return ushort(v);
never executed: return ushort(v);
0
1301} -
1302double QByteArray::toDouble(bool *ok) const -
1303{ -
1304 return QLocalePrivate::bytearrayToDouble(nulTerminated().constData(), ok);
executed: return QLocalePrivate::bytearrayToDouble(nulTerminated().constData(), ok);
Execution Count:395
395
1305} -
1306float QByteArray::toFloat(bool *ok) const -
1307{ -
1308 return float(toDouble(ok));
executed: return float(toDouble(ok));
Execution Count:1
1
1309} -
1310QByteArray QByteArray::toBase64() const -
1311{ -
1312 const char alphabet[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" -
1313 "ghijklmn" "opqrstuv" "wxyz0123" "456789+/"; -
1314 const char padchar = '='; -
1315 int padlen = 0; -
1316 -
1317 QByteArray tmp((d->size * 4) / 3 + 3, Qt::Uninitialized); -
1318 -
1319 int i = 0; -
1320 char *out = tmp.data(); -
1321 while (i < d->size) {
evaluated: i < d->size
TRUEFALSE
yes
Evaluation Count:756025
yes
Evaluation Count:596
596-756025
1322 int chunk = 0; -
1323 chunk |= int(uchar(d->data()[i++])) << 16; -
1324 if (i == d->size) {
evaluated: i == d->size
TRUEFALSE
yes
Evaluation Count:234
yes
Evaluation Count:755791
234-755791
1325 padlen = 2; -
1326 } else {
executed: }
Execution Count:234
234
1327 chunk |= int(uchar(d->data()[i++])) << 8; -
1328 if (i == d->size) padlen = 1;
executed: padlen = 1;
Execution Count:191
evaluated: i == d->size
TRUEFALSE
yes
Evaluation Count:191
yes
Evaluation Count:755600
191-755600
1329 else chunk |= int(uchar(d->data()[i++]));
executed: chunk |= int(uchar(d->data()[i++]));
Execution Count:755600
755600
1330 } -
1331 -
1332 int j = (chunk & 0x00fc0000) >> 18; -
1333 int k = (chunk & 0x0003f000) >> 12; -
1334 int l = (chunk & 0x00000fc0) >> 6; -
1335 int m = (chunk & 0x0000003f); -
1336 *out++ = alphabet[j]; -
1337 *out++ = alphabet[k]; -
1338 if (padlen > 1) *out++ = padchar;
executed: *out++ = padchar;
Execution Count:234
evaluated: padlen > 1
TRUEFALSE
yes
Evaluation Count:234
yes
Evaluation Count:755791
234-755791
1339 else *out++ = alphabet[l];
executed: *out++ = alphabet[l];
Execution Count:755791
755791
1340 if (padlen > 0) *out++ = padchar;
executed: *out++ = padchar;
Execution Count:425
evaluated: padlen > 0
TRUEFALSE
yes
Evaluation Count:425
yes
Evaluation Count:755600
425-755600
1341 else *out++ = alphabet[m];
executed: *out++ = alphabet[m];
Execution Count:755600
755600
1342 } -
1343 -
1344 tmp.truncate(out - tmp.data()); -
1345 return tmp;
executed: return tmp;
Execution Count:596
596
1346} -
1347static char *qulltoa2(char *p, qulonglong n, int base) -
1348{ -
1349 -
1350 -
1351 -
1352 -
1353 -
1354 -
1355 const char b = 'a' - 10; -
1356 do { -
1357 const int c = n % base; -
1358 n /= base; -
1359 *--p = c + (c < 10 ? '0' : b);
evaluated: c < 10
TRUEFALSE
yes
Evaluation Count:2271121
yes
Evaluation Count:20957
20957-2271121
1360 } while (n);
executed: }
Execution Count:2292078
evaluated: n
TRUEFALSE
yes
Evaluation Count:1850073
yes
Evaluation Count:442005
442005-2292078
1361 -
1362 return p;
executed: return p;
Execution Count:442005
442005
1363} -
1364 -
1365QByteArray &QByteArray::setNum(qlonglong n, int base) -
1366{ -
1367 const int buffsize = 66; -
1368 char buff[buffsize]; -
1369 char *p; -
1370 -
1371 if (n < 0 && base == 10) {
evaluated: n < 0
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:417137
evaluated: base == 10
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:136
12-417137
1372 p = qulltoa2(buff + buffsize, qulonglong(-(1 + n)) + 1, base); -
1373 *--p = '-'; -
1374 } else {
executed: }
Execution Count:12
12
1375 p = qulltoa2(buff + buffsize, qulonglong(n), base); -
1376 }
executed: }
Execution Count:417273
417273
1377 -
1378 clear(); -
1379 append(p, buffsize - (p - buff)); -
1380 return *this;
executed: return *this;
Execution Count:417285
417285
1381} -
1382 -
1383 -
1384 -
1385 -
1386 -
1387 -
1388 -
1389QByteArray &QByteArray::setNum(qulonglong n, int base) -
1390{ -
1391 const int buffsize = 66; -
1392 char buff[buffsize]; -
1393 char *p = qulltoa2(buff + buffsize, n, base); -
1394 -
1395 clear(); -
1396 append(p, buffsize - (p - buff)); -
1397 return *this;
executed: return *this;
Execution Count:24720
24720
1398} -
1399QByteArray &QByteArray::setNum(double n, char f, int prec) -
1400{ -
1401 QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; -
1402 uint flags = 0; -
1403 -
1404 if (qIsUpper(f))
partially evaluated: qIsUpper(f)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:450222
0-450222
1405 flags = QLocalePrivate::CapitalEorX;
never executed: flags = QLocalePrivate::CapitalEorX;
0
1406 f = qToLower(f); -
1407 -
1408 switch (f) { -
1409 case 'f': -
1410 form = QLocalePrivate::DFDecimal; -
1411 break;
never executed: break;
0
1412 case 'e': -
1413 form = QLocalePrivate::DFExponent; -
1414 break;
never executed: break;
0
1415 case 'g': -
1416 form = QLocalePrivate::DFSignificantDigits; -
1417 break;
executed: break;
Execution Count:450222
450222
1418 default: -
1419 -
1420 -
1421 -
1422 break;
never executed: break;
0
1423 } -
1424 -
1425 QLocale locale(QLocale::C); -
1426 *this = locale.d->doubleToString(n, prec, form, -1, flags).toLatin1(); -
1427 return *this;
executed: return *this;
Execution Count:450222
450222
1428} -
1429QByteArray QByteArray::number(int n, int base) -
1430{ -
1431 QByteArray s; -
1432 s.setNum(n, base); -
1433 return s;
executed: return s;
Execution Count:420949
420949
1434} -
1435 -
1436 -
1437 -
1438 -
1439 -
1440 -
1441QByteArray QByteArray::number(uint n, int base) -
1442{ -
1443 QByteArray s; -
1444 s.setNum(n, base); -
1445 return s;
executed: return s;
Execution Count:20316
20316
1446} -
1447 -
1448 -
1449 -
1450 -
1451 -
1452 -
1453QByteArray QByteArray::number(qlonglong n, int base) -
1454{ -
1455 QByteArray s; -
1456 s.setNum(n, base); -
1457 return s;
executed: return s;
Execution Count:711
711
1458} -
1459 -
1460 -
1461 -
1462 -
1463 -
1464 -
1465QByteArray QByteArray::number(qulonglong n, int base) -
1466{ -
1467 QByteArray s; -
1468 s.setNum(n, base); -
1469 return s;
executed: return s;
Execution Count:6
6
1470} -
1471QByteArray QByteArray::number(double n, char f, int prec) -
1472{ -
1473 QByteArray s; -
1474 s.setNum(n, f, prec); -
1475 return s;
executed: return s;
Execution Count:450219
450219
1476} -
1477QByteArray QByteArray::fromRawData(const char *data, int size) -
1478{ -
1479 Data *x; -
1480 if (!data) {
partially evaluated: !data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1888933
0-1888933
1481 x = Data::sharedNull(); -
1482 } else if (!size) {
never executed: }
evaluated: !size
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:1888900
0-1888900
1483 x = Data::allocate(0); -
1484 } else {
executed: }
Execution Count:34
34
1485 x = Data::fromRawData(data, size); -
1486 do { if (!(x)) qBadAlloc(); } while (0);
never executed: qBadAlloc();
executed: }
Execution Count:1888894
partially evaluated: !(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1888896
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1888895
0-1888896
1487 }
executed: }
Execution Count:1888895
1888895
1488 QByteArrayDataPtr dataPtr = { reinterpret_cast<QByteArrayData *>(x) }; -
1489 return QByteArray(dataPtr);
executed: return QByteArray(dataPtr);
Execution Count:1888931
1888931
1490} -
1491QByteArray &QByteArray::setRawData(const char *data, uint size) -
1492{ -
1493 if (d->ref.isShared() || d->alloc) {
never evaluated: d->ref.isShared()
never evaluated: d->alloc
0
1494 *this = fromRawData(data, size); -
1495 } else {
never executed: }
0
1496 if (data) {
never evaluated: data
0
1497 d->size = size; -
1498 d->offset = data - reinterpret_cast<char *>(d); -
1499 } else {
never executed: }
0
1500 d->offset = sizeof(QByteArrayData); -
1501 d->size = 0; -
1502 *d->data() = 0; -
1503 }
never executed: }
0
1504 } -
1505 return *this;
never executed: return *this;
0
1506} -
1507QByteArray QByteArray::fromBase64(const QByteArray &base64) -
1508{ -
1509 unsigned int buf = 0; -
1510 int nbits = 0; -
1511 QByteArray tmp((base64.size() * 3) / 4, Qt::Uninitialized); -
1512 -
1513 int offset = 0; -
1514 for (int i = 0; i < base64.size(); ++i) {
evaluated: i < base64.size()
TRUEFALSE
yes
Evaluation Count:3804163
yes
Evaluation Count:1315
1315-3804163
1515 int ch = base64.at(i); -
1516 int d; -
1517 -
1518 if (ch >= 'A' && ch <= 'Z')
evaluated: ch >= 'A'
TRUEFALSE
yes
Evaluation Count:3323384
yes
Evaluation Count:480779
evaluated: ch <= 'Z'
TRUEFALSE
yes
Evaluation Count:2079472
yes
Evaluation Count:1243912
480779-3323384
1519 d = ch - 'A';
executed: d = ch - 'A';
Execution Count:2079472
2079472
1520 else if (ch >= 'a' && ch <= 'z')
evaluated: ch >= 'a'
TRUEFALSE
yes
Evaluation Count:1243912
yes
Evaluation Count:480779
partially evaluated: ch <= 'z'
TRUEFALSE
yes
Evaluation Count:1243912
no
Evaluation Count:0
0-1243912
1521 d = ch - 'a' + 26;
executed: d = ch - 'a' + 26;
Execution Count:1243912
1243912
1522 else if (ch >= '0' && ch <= '9')
evaluated: ch >= '0'
TRUEFALSE
yes
Evaluation Count:416525
yes
Evaluation Count:64254
evaluated: ch <= '9'
TRUEFALSE
yes
Evaluation Count:414982
yes
Evaluation Count:1543
1543-416525
1523 d = ch - '0' + 52;
executed: d = ch - '0' + 52;
Execution Count:414982
414982
1524 else if (ch == '+')
evaluated: ch == '+'
TRUEFALSE
yes
Evaluation Count:22115
yes
Evaluation Count:43682
22115-43682
1525 d = 62;
executed: d = 62;
Execution Count:22115
22115
1526 else if (ch == '/')
evaluated: ch == '/'
TRUEFALSE
yes
Evaluation Count:26051
yes
Evaluation Count:17631
17631-26051
1527 d = 63;
executed: d = 63;
Execution Count:26051
26051
1528 else -
1529 d = -1;
executed: d = -1;
Execution Count:17631
17631
1530 -
1531 if (d != -1) {
evaluated: d != -1
TRUEFALSE
yes
Evaluation Count:3786532
yes
Evaluation Count:17631
17631-3786532
1532 buf = (buf << 6) | d; -
1533 nbits += 6; -
1534 if (nbits >= 8) {
evaluated: nbits >= 8
TRUEFALSE
yes
Evaluation Count:2839534
yes
Evaluation Count:946998
946998-2839534
1535 nbits -= 8; -
1536 tmp[offset++] = buf >> nbits; -
1537 buf &= (1 << nbits) - 1; -
1538 }
executed: }
Execution Count:2839534
2839534
1539 }
executed: }
Execution Count:3786532
3786532
1540 }
executed: }
Execution Count:3804163
3804163
1541 -
1542 tmp.truncate(offset); -
1543 return tmp;
executed: return tmp;
Execution Count:1315
1315
1544} -
1545QByteArray QByteArray::fromHex(const QByteArray &hexEncoded) -
1546{ -
1547 QByteArray res((hexEncoded.size() + 1)/ 2, Qt::Uninitialized); -
1548 uchar *result = (uchar *)res.data() + res.size(); -
1549 -
1550 bool odd_digit = true; -
1551 for (int i = hexEncoded.size() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:5648
yes
Evaluation Count:66
66-5648
1552 int ch = hexEncoded.at(i); -
1553 int tmp; -
1554 if (ch >= '0' && ch <= '9')
evaluated: ch >= '0'
TRUEFALSE
yes
Evaluation Count:5615
yes
Evaluation Count:33
evaluated: ch <= '9'
TRUEFALSE
yes
Evaluation Count:3170
yes
Evaluation Count:2445
33-5615
1555 tmp = ch - '0';
executed: tmp = ch - '0';
Execution Count:3170
3170
1556 else if (ch >= 'a' && ch <= 'f')
evaluated: ch >= 'a'
TRUEFALSE
yes
Evaluation Count:631
yes
Evaluation Count:1847
evaluated: ch <= 'f'
TRUEFALSE
yes
Evaluation Count:609
yes
Evaluation Count:22
22-1847
1557 tmp = ch - 'a' + 10;
executed: tmp = ch - 'a' + 10;
Execution Count:609
609
1558 else if (ch >= 'A' && ch <= 'F')
evaluated: ch >= 'A'
TRUEFALSE
yes
Evaluation Count:860
yes
Evaluation Count:1009
evaluated: ch <= 'F'
TRUEFALSE
yes
Evaluation Count:838
yes
Evaluation Count:22
22-1009
1559 tmp = ch - 'A' + 10;
executed: tmp = ch - 'A' + 10;
Execution Count:838
838
1560 else -
1561 continue;
executed: continue;
Execution Count:1031
1031
1562 if (odd_digit) {
evaluated: odd_digit
TRUEFALSE
yes
Evaluation Count:2311
yes
Evaluation Count:2306
2306-2311
1563 --result; -
1564 *result = tmp; -
1565 odd_digit = false; -
1566 } else {
executed: }
Execution Count:2311
2311
1567 *result |= tmp << 4; -
1568 odd_digit = true; -
1569 }
executed: }
Execution Count:2306
2306
1570 } -
1571 -
1572 res.remove(0, result - (const uchar *)res.constData()); -
1573 return res;
executed: return res;
Execution Count:66
66
1574} -
1575 -
1576 -
1577 -
1578 -
1579 -
1580 -
1581 -
1582QByteArray QByteArray::toHex() const -
1583{ -
1584 QByteArray hex(d->size * 2, Qt::Uninitialized); -
1585 char *hexData = hex.data(); -
1586 const uchar *data = (const uchar *)d->data(); -
1587 for (int i = 0; i < d->size; ++i) {
evaluated: i < d->size
TRUEFALSE
yes
Evaluation Count:35977
yes
Evaluation Count:2007
2007-35977
1588 int j = (data[i] >> 4) & 0xf; -
1589 if (j <= 9)
evaluated: j <= 9
TRUEFALSE
yes
Evaluation Count:26259
yes
Evaluation Count:9718
9718-26259
1590 hexData[i*2] = (j + '0');
executed: hexData[i*2] = (j + '0');
Execution Count:26259
26259
1591 else -
1592 hexData[i*2] = (j + 'a' - 10);
executed: hexData[i*2] = (j + 'a' - 10);
Execution Count:9718
9718
1593 j = data[i] & 0xf; -
1594 if (j <= 9)
evaluated: j <= 9
TRUEFALSE
yes
Evaluation Count:21656
yes
Evaluation Count:14321
14321-21656
1595 hexData[i*2+1] = (j + '0');
executed: hexData[i*2+1] = (j + '0');
Execution Count:21656
21656
1596 else -
1597 hexData[i*2+1] = (j + 'a' - 10);
executed: hexData[i*2+1] = (j + 'a' - 10);
Execution Count:14321
14321
1598 } -
1599 return hex;
executed: return hex;
Execution Count:2007
2007
1600} -
1601 -
1602static void q_fromPercentEncoding(QByteArray *ba, char percent) -
1603{ -
1604 if (ba->isEmpty())
partially evaluated: ba->isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
0-60
1605 return;
never executed: return;
0
1606 -
1607 char *data = ba->data(); -
1608 const char *inputPtr = data; -
1609 -
1610 int i = 0; -
1611 int len = ba->count(); -
1612 int outlen = 0; -
1613 int a, b; -
1614 char c; -
1615 while (i < len) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:1853
yes
Evaluation Count:60
60-1853
1616 c = inputPtr[i]; -
1617 if (c == percent && i + 2 < len) {
evaluated: c == percent
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:1710
partially evaluated: i + 2 < len
TRUEFALSE
yes
Evaluation Count:143
no
Evaluation Count:0
0-1710
1618 a = inputPtr[++i]; -
1619 b = inputPtr[++i]; -
1620 -
1621 if (a >= '0' && a <= '9') a -= '0';
executed: a -= '0';
Execution Count:136
partially evaluated: a >= '0'
TRUEFALSE
yes
Evaluation Count:143
no
Evaluation Count:0
evaluated: a <= '9'
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:7
0-143
1622 else if (a >= 'a' && a <= 'f') a = a - 'a' + 10;
never executed: a = a - 'a' + 10;
partially evaluated: a >= 'a'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
never evaluated: a <= 'f'
0-7
1623 else if (a >= 'A' && a <= 'F') a = a - 'A' + 10;
executed: a = a - 'A' + 10;
Execution Count:7
partially evaluated: a >= 'A'
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
partially evaluated: a <= 'F'
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1624 -
1625 if (b >= '0' && b <= '9') b -= '0';
executed: b -= '0';
Execution Count:76
partially evaluated: b >= '0'
TRUEFALSE
yes
Evaluation Count:143
no
Evaluation Count:0
evaluated: b <= '9'
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:67
0-143
1626 else if (b >= 'a' && b <= 'f') b = b - 'a' + 10;
never executed: b = b - 'a' + 10;
partially evaluated: b >= 'a'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:67
never evaluated: b <= 'f'
0-67
1627 else if (b >= 'A' && b <= 'F') b = b - 'A' + 10;
executed: b = b - 'A' + 10;
Execution Count:67
partially evaluated: b >= 'A'
TRUEFALSE
yes
Evaluation Count:67
no
Evaluation Count:0
partially evaluated: b <= 'F'
TRUEFALSE
yes
Evaluation Count:67
no
Evaluation Count:0
0-67
1628 -
1629 *data++ = (char)((a << 4) | b); -
1630 } else {
executed: }
Execution Count:143
143
1631 *data++ = c; -
1632 }
executed: }
Execution Count:1710
1710
1633 -
1634 ++i; -
1635 ++outlen; -
1636 }
executed: }
Execution Count:1853
1853
1637 -
1638 if (outlen != len)
evaluated: outlen != len
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:26
26-34
1639 ba->truncate(outlen);
executed: ba->truncate(outlen);
Execution Count:34
34
1640}
executed: }
Execution Count:60
60
1641 -
1642void q_fromPercentEncoding(QByteArray *ba) -
1643{ -
1644 q_fromPercentEncoding(ba, '%'); -
1645}
never executed: }
0
1646QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent) -
1647{ -
1648 if (input.isNull())
evaluated: input.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:64
2-64
1649 return QByteArray();
executed: return QByteArray();
Execution Count:2
2
1650 if (input.isEmpty())
evaluated: input.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:60
4-60
1651 return QByteArray(input.data(), 0);
executed: return QByteArray(input.data(), 0);
Execution Count:4
4
1652 -
1653 QByteArray tmp = input; -
1654 q_fromPercentEncoding(&tmp, percent); -
1655 return tmp;
executed: return tmp;
Execution Count:60
60
1656} -
1657 -
1658static inline bool q_strchr(const char str[], char chr) -
1659{ -
1660 if (!str) return false;
never executed: return false;
partially evaluated: !str
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:446
0-446
1661 -
1662 const char *ptr = str; -
1663 char c; -
1664 while ((c = *ptr++))
evaluated: (c = *ptr++)
TRUEFALSE
yes
Evaluation Count:516
yes
Evaluation Count:397
397-516
1665 if (c == chr)
evaluated: c == chr
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:467
49-467
1666 return true;
executed: return true;
Execution Count:49
49
1667 return false;
executed: return false;
Execution Count:397
397
1668} -
1669 -
1670static inline char toHexHelper(char c) -
1671{ -
1672 static const char hexnumbers[] = "0123456789ABCDEF"; -
1673 return hexnumbers[c & 0xf];
executed: return hexnumbers[c & 0xf];
Execution Count:212
212
1674} -
1675 -
1676static void q_toPercentEncoding(QByteArray *ba, const char *dontEncode, const char *alsoEncode, char percent) -
1677{ -
1678 if (ba->isEmpty())
partially evaluated: ba->isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
1679 return;
never executed: return;
0
1680 -
1681 QByteArray input = *ba; -
1682 int len = input.count(); -
1683 const char *inputData = input.constData(); -
1684 char *output = 0; -
1685 int length = 0; -
1686 -
1687 for (int i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:413
yes
Evaluation Count:26
26-413
1688 unsigned char c = *inputData++; -
1689 if (((c >= 0x61 && c <= 0x7A)
evaluated: c >= 0x61
TRUEFALSE
yes
Evaluation Count:210
yes
Evaluation Count:203
evaluated: c <= 0x7A
TRUEFALSE
yes
Evaluation Count:200
yes
Evaluation Count:10
10-210
1690 || (c >= 0x41 && c <= 0x5A)
evaluated: c >= 0x41
TRUEFALSE
yes
Evaluation Count:80
yes
Evaluation Count:133
evaluated: c <= 0x5A
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:22
22-133
1691 || (c >= 0x30 && c <= 0x39)
evaluated: c >= 0x30
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:91
evaluated: c <= 0x39
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:46
18-91
1692 || c == 0x2D
evaluated: c == 0x2D
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:131
6-131
1693 || c == 0x2E
evaluated: c == 0x2E
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:127
4-127
1694 || c == 0x5F
evaluated: c == 0x5F
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:125
2-125
1695 || c == 0x7E
evaluated: c == 0x7E
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:123
2-123
1696 || q_strchr(dontEncode, c))
evaluated: q_strchr(dontEncode, c)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:90
33-90
1697 && !q_strchr(alsoEncode, c)) {
evaluated: !q_strchr(alsoEncode, c)
TRUEFALSE
yes
Evaluation Count:307
yes
Evaluation Count:16
16-307
1698 if (output)
evaluated: output
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:183
124-183
1699 output[length] = c;
executed: output[length] = c;
Execution Count:124
124
1700 ++length; -
1701 } else {
executed: }
Execution Count:307
307
1702 if (!output) {
evaluated: !output
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:84
22-84
1703 -
1704 ba->resize(len*3); -
1705 output = ba->data(); -
1706 }
executed: }
Execution Count:22
22
1707 output[length++] = percent; -
1708 output[length++] = toHexHelper((c & 0xf0) >> 4); -
1709 output[length++] = toHexHelper(c & 0xf); -
1710 }
executed: }
Execution Count:106
106
1711 } -
1712 if (output)
evaluated: output
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:4
4-22
1713 ba->truncate(length);
executed: ba->truncate(length);
Execution Count:22
22
1714}
executed: }
Execution Count:26
26
1715 -
1716void q_toPercentEncoding(QByteArray *ba, const char *exclude, const char *include) -
1717{ -
1718 q_toPercentEncoding(ba, exclude, include, '%'); -
1719}
never executed: }
0
1720 -
1721void q_normalizePercentEncoding(QByteArray *ba, const char *exclude) -
1722{ -
1723 q_fromPercentEncoding(ba, '%'); -
1724 q_toPercentEncoding(ba, exclude, 0, '%'); -
1725}
never executed: }
0
1726QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteArray &include, -
1727 char percent) const -
1728{ -
1729 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:30
2-30
1730 return QByteArray();
executed: return QByteArray();
Execution Count:2
2
1731 if (isEmpty())
evaluated: isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:26
4-26
1732 return QByteArray(data(), 0);
executed: return QByteArray(data(), 0);
Execution Count:4
4
1733 -
1734 QByteArray include2 = include; -
1735 if (percent != '%')
evaluated: percent != '%'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:25
1-25
1736 if ((percent >= 0x61 && percent <= 0x7A)
partially evaluated: percent >= 0x61
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: percent <= 0x7A
0-1
1737 || (percent >= 0x41 && percent <= 0x5A)
partially evaluated: percent >= 0x41
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: percent <= 0x5A
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1738 || (percent >= 0x30 && percent <= 0x39)
never evaluated: percent >= 0x30
never evaluated: percent <= 0x39
0
1739 || percent == 0x2D
never evaluated: percent == 0x2D
0
1740 || percent == 0x2E
never evaluated: percent == 0x2E
0
1741 || percent == 0x5F
never evaluated: percent == 0x5F
0
1742 || percent == 0x7E)
never evaluated: percent == 0x7E
0
1743 include2 += percent;
executed: include2 += percent;
Execution Count:1
1
1744 -
1745 QByteArray result = *this; -
1746 q_toPercentEncoding(&result, exclude.nulTerminated().constData(), include2.nulTerminated().constData(), percent); -
1747 -
1748 return result;
executed: return result;
Execution Count:26
26
1749} -
1750 -
1751 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial