global/qmalloc.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5__attribute__((visibility("default"))) void *qMalloc(size_t size) __attribute__((alloc_size(1))); -
6__attribute__((visibility("default"))) void qFree(void *ptr); -
7__attribute__((visibility("default"))) void *qRealloc(void *ptr, size_t size) __attribute__((alloc_size(2))); -
8 -
9 -
10 -
11void *qMalloc(size_t size) -
12{ -
13 return ::malloc(size);
never executed: return ::malloc(size);
0
14} -
15 -
16void qFree(void *ptr) -
17{ -
18 ::free(ptr); -
19}
never executed: }
0
20 -
21void *qRealloc(void *ptr, size_t size) -
22{ -
23 return ::realloc(ptr, size);
never executed: return ::realloc(ptr, size);
0
24} -
25 -
26void *qMallocAligned(size_t size, size_t alignment) -
27{ -
28 return qReallocAligned(0, size, 0, alignment);
executed: return qReallocAligned(0, size, 0, alignment);
Execution Count:1440
1440
29} -
30 -
31void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment) -
32{ -
33 -
34 (void)oldsize;; -
35 -
36 void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : 0;
partially evaluated: oldptr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1440
0-1440
37 if (alignment <= sizeof(void*)) {
evaluated: alignment <= sizeof(void*)
TRUEFALSE
yes
Evaluation Count:239
yes
Evaluation Count:1201
239-1201
38 -
39 void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*))); -
40 if (!newptr)
partially evaluated: !newptr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:239
0-239
41 return 0;
never executed: return 0;
0
42 if (newptr == actualptr) {
partially evaluated: newptr == actualptr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:239
0-239
43 -
44 return oldptr;
never executed: return oldptr;
0
45 } -
46 -
47 *newptr = newptr; -
48 return newptr + 1;
executed: return newptr + 1;
Execution Count:239
239
49 } -
50 void *real = realloc(actualptr, newsize + alignment); -
51 if (!real)
partially evaluated: !real
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1201
0-1201
52 return 0;
never executed: return 0;
0
53 -
54 quintptr faked = reinterpret_cast<quintptr>(real) + alignment; -
55 faked &= ~(alignment - 1); -
56 -
57 void **faked_ptr = reinterpret_cast<void **>(faked); -
58 -
59 -
60 -
61 -
62 faked_ptr[-1] = real; -
63 -
64 return faked_ptr;
executed: return faked_ptr;
Execution Count:1201
1201
65} -
66 -
67void qFreeAligned(void *ptr) -
68{ -
69 if (!ptr)
evaluated: !ptr
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1437
2-1437
70 return;
executed: return;
Execution Count:2
2
71 void **ptr2 = static_cast<void **>(ptr); -
72 free(ptr2[-1]); -
73}
executed: }
Execution Count:1437
1437
74 -
75 -
76 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial