qmalloc.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/global/qmalloc.cpp
Switch to Source codePreprocessed file
LineSourceCount
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
never executed: return ::malloc(size);
::malloc(size);
never executed: return ::malloc(size);
0
14}-
15-
16void qFree(void *ptr)-
17{-
18 ::free(ptr);-
19}
never executed: end of block
0
20-
21void *qRealloc(void *ptr, size_t size)-
22{-
23 return
never executed: return ::realloc(ptr, size);
::realloc(ptr, size);
never executed: return ::realloc(ptr, size);
0
24}-
25-
26void *qMallocAligned(size_t size, size_t alignment)-
27{-
28 return
executed 1462 times by 4 tests: return qReallocAligned(0, size, 0, alignment);
Executed by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
qReallocAligned(0, size, 0, alignment);
executed 1462 times by 4 tests: return qReallocAligned(0, size, 0, alignment);
Executed by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
1462
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
oldptrDescription
TRUEnever evaluated
FALSEevaluated 1462 times by 4 tests
Evaluated by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
? static_cast<void **>(oldptr)[-1] : 0;
0-1462
37 if (alignment <= sizeof(void*)
alignment <= sizeof(void*)Description
TRUEevaluated 261 times by 4 tests
Evaluated by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
FALSEevaluated 1201 times by 1 test
Evaluated by:
  • tst_Collections
) {
261-1201
38-
39 void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*)));-
40 if (!newptr
!newptrDescription
TRUEnever evaluated
FALSEevaluated 261 times by 4 tests
Evaluated by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
)
0-261
41 return
never executed: return 0;
0;
never executed: return 0;
0
42 if (newptr == actualptr
newptr == actualptrDescription
TRUEnever evaluated
FALSEevaluated 261 times by 4 tests
Evaluated by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
) {
0-261
43-
44 return
never executed: return oldptr;
oldptr;
never executed: return oldptr;
0
45 }-
46-
47 *newptr = newptr;-
48 return
executed 261 times by 4 tests: return newptr + 1;
Executed by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
newptr + 1;
executed 261 times by 4 tests: return newptr + 1;
Executed by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
261
49 }-
50 void *real = realloc(actualptr, newsize + alignment);-
51 if (!real
!realDescription
TRUEnever evaluated
FALSEevaluated 1201 times by 1 test
Evaluated by:
  • tst_Collections
)
0-1201
52 return
never executed: return 0;
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
executed 1201 times by 1 test: return faked_ptr;
Executed by:
  • tst_Collections
faked_ptr;
executed 1201 times by 1 test: return faked_ptr;
Executed by:
  • tst_Collections
1201
65}-
66-
67void qFreeAligned(void *ptr)-
68{-
69 if (!ptr
!ptrDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 1459 times by 4 tests
Evaluated by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
)
2-1459
70 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_QMetaType
2
71 void **ptr2 = static_cast<void **>(ptr);-
72 free(ptr2[-1]);-
73}
executed 1459 times by 4 tests: end of block
Executed by:
  • tst_Collections
  • tst_QContiguousCache
  • tst_QGuiMetaType
  • tst_QMetaType
1459
74-
75-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9