Skip to content

Commit 203315a

Browse files
committed
Assign malloc results in test to variables.
1 parent 230e5a3 commit 203315a

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

cpp/ql/test/library-tests/allocators/allocators.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@ void directOperatorCall() {
151151
}
152152

153153
void *malloc(size_t);
154+
typedef int* ptr_int;
154155

155156
void testMalloc(size_t count) {
156-
malloc(5);
157-
malloc(5 * sizeof(int));
158-
malloc(count);
159-
malloc(count * sizeof(int));
160-
malloc(count * sizeof(int) + 1);
161-
malloc(((int) count) * sizeof(void *));
162-
malloc(sizeof(void*) * sizeof(int));
157+
const volatile int *i = (const volatile int *) malloc(5);
158+
ptr_int i2 = (ptr_int) malloc(5 * sizeof(int));
159+
volatile long *l = (long *) malloc(count);
160+
l = (long *) malloc(count * sizeof(int));
161+
const char* c = (const char *) malloc(count * sizeof(int) + 1);
162+
void * v = (void *) malloc(((int) count) * sizeof(void *));
163+
malloc(sizeof(void *) * sizeof(int));
163164
}

cpp/ql/test/library-tests/allocators/allocators.expected

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ allocationExprs
8585
| allocators.cpp:143:13:143:28 | new[] | getSizeBytes = 400, requiresDealloc |
8686
| allocators.cpp:144:13:144:31 | new[] | getSizeExpr = x, getSizeMult = 900, requiresDealloc |
8787
| allocators.cpp:149:8:149:19 | call to operator new | getSizeBytes = 4, getSizeExpr = sizeof(int), getSizeMult = 1, requiresDealloc |
88-
| allocators.cpp:156:3:156:8 | call to malloc | getSizeBytes = 5, getSizeExpr = 5, getSizeMult = 1, requiresDealloc |
89-
| allocators.cpp:157:3:157:8 | call to malloc | getSizeBytes = 20, getSizeExpr = 5, getSizeMult = 4, requiresDealloc |
90-
| allocators.cpp:158:3:158:8 | call to malloc | getSizeExpr = count, getSizeMult = 1, requiresDealloc |
91-
| allocators.cpp:159:3:159:8 | call to malloc | getSizeExpr = count, getSizeMult = 4, requiresDealloc |
92-
| allocators.cpp:160:3:160:8 | call to malloc | getSizeExpr = ... + ..., getSizeMult = 1, requiresDealloc |
93-
| allocators.cpp:161:3:161:8 | call to malloc | getSizeExpr = count, getSizeMult = 8, requiresDealloc |
94-
| allocators.cpp:162:3:162:8 | call to malloc | getSizeBytes = 32, getSizeExpr = ... * ..., getSizeMult = 1, requiresDealloc |
88+
| allocators.cpp:157:50:157:55 | call to malloc | getSizeBytes = 5, getSizeExpr = 5, getSizeMult = 1, requiresDealloc |
89+
| allocators.cpp:158:26:158:31 | call to malloc | getSizeBytes = 20, getSizeExpr = 5, getSizeMult = 4, requiresDealloc |
90+
| allocators.cpp:159:31:159:36 | call to malloc | getSizeExpr = count, getSizeMult = 1, requiresDealloc |
91+
| allocators.cpp:160:16:160:21 | call to malloc | getSizeExpr = count, getSizeMult = 4, requiresDealloc |
92+
| allocators.cpp:161:34:161:39 | call to malloc | getSizeExpr = ... + ..., getSizeMult = 1, requiresDealloc |
93+
| allocators.cpp:162:23:162:28 | call to malloc | getSizeExpr = count, getSizeMult = 8, requiresDealloc |
94+
| allocators.cpp:163:3:163:8 | call to malloc | getSizeBytes = 32, getSizeExpr = ... * ..., getSizeMult = 1, requiresDealloc |
9595
deallocationFunctions
9696
| allocators.cpp:11:6:11:20 | operator delete | getFreedArg = 0 |
9797
| allocators.cpp:12:6:12:22 | operator delete[] | getFreedArg = 0 |

0 commit comments

Comments
 (0)