1 //===-- main.c --------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #include <pthread.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 char *pointer;
13 
14 void *f1(void *p) {
15     pointer[0] = 'x'; // thread1 line
16     return NULL;
17 }
18 
19 void *f2(void *p) {
20     pointer[0] = 'y'; // thread2 line
21     return NULL;
22 }
23 
24 int main (int argc, char const *argv[])
25 {
26     pointer = (char *)malloc(10); // malloc line
27 
28     pthread_t t1, t2;
29     pthread_create(&t1, NULL, f1, NULL);
30     pthread_create(&t2, NULL, f2, NULL);
31 
32     pthread_join(t1, NULL);
33     pthread_join(t2, NULL);
34 
35     return 0;
36 }
37