1 // RUN: %clang_scudo %s -o %t
2 // RUN: %run %t 2>&1
3 
4 // Tests that a regular workflow of allocation, memory fill and free works as
5 // intended. Also tests that a zero-sized allocation succeeds.
6 
7 #include <malloc.h>
8 #include <stdlib.h>
9 #include <string.h>
10 
11 #include <vector>
12 
13 int main(int argc, char **argv)
14 {
15   void *p;
16   std::vector<size_t> sizes{1, 1 << 5, 1 << 10, 1 << 15, 1 << 20};
17 
18   p = malloc(0);
19   if (!p)
20     return 1;
21   free(p);
22   for (size_t size : sizes) {
23     p = malloc(size);
24     if (!p)
25       return 1;
26     memset(p, 'A', size);
27     free(p);
28   }
29 
30   return 0;
31 }
32