-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest033.c
More file actions
37 lines (33 loc) · 1.21 KB
/
test033.c
File metadata and controls
37 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "cs0019.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
// Memory leak report with multiple leaks.
int main() {
char *ptrs[10];
ptrs[0] = (char *)malloc(10);
ptrs[1] = (char *)malloc(11);
ptrs[2] = (char *)malloc(12);
ptrs[3] = (char *)malloc(13);
ptrs[4] = (char *)malloc(14);
ptrs[5] = (char *)malloc(15);
ptrs[6] = (char *)malloc(16);
ptrs[7] = (char *)malloc(17);
ptrs[8] = (char *)malloc(18);
ptrs[9] = (char *)malloc(19);
free(ptrs[3]);
free(ptrs[8]);
free(ptrs[0]);
cs0019_printleakreport();
}
// The "//!!SORT" line tells the check.pl script to sort your program's
// output before comparing it with the list below.
// That's so your program can output its reports in any order.
//!!SORT
//! LEAK CHECK: test???.c:10: allocated object ??{\w+}?? with size 11
//! LEAK CHECK: test???.c:11: allocated object ??{\w+}?? with size 12
//! LEAK CHECK: test???.c:13: allocated object ??{\w+}?? with size 14
//! LEAK CHECK: test???.c:14: allocated object ??{\w+}?? with size 15
//! LEAK CHECK: test???.c:15: allocated object ??{\w+}?? with size 16
//! LEAK CHECK: test???.c:16: allocated object ??{\w+}?? with size 17
//! LEAK CHECK: test???.c:18: allocated object ??{\w+}?? with size 19