Prepare for '-Wunused-parameter'
[lttng-tools.git] / tests / regression / ust / libc-wrapper / prog.c
CommitLineData
9d16b343 1/* Copyright (C) 2009 Pierre-Marc Fournier
5836cdc2 2 *
9d16b343 3 * SPDX-License-Identifier: LGPL-2.1-only
5836cdc2 4 *
5836cdc2
JG
5 */
6
7/* This program is used to test malloc instrumentation with libustinstr-malloc.
8 */
9
10#include <string.h>
11#include <stdlib.h>
12
13#define N_ITER 1000
14
f46376a1 15int main(void)
5836cdc2
JG
16{
17 int i;
18 const char teststr[] = "Hello World! 1234567890abc";
19 void *ptrs[N_ITER];
20
21 for (i = 0; i < N_ITER; i++) {
22 ptrs[i] = malloc(i+1000);
ca72068e
MD
23 if (!ptrs[i]) {
24 exit(EXIT_FAILURE);
25 }
5836cdc2
JG
26
27 memcpy(ptrs[i], teststr, sizeof(teststr));
28
29 if (i % 2 == 0) {
30 free(ptrs[i]);
31 }
32 }
33
34 for (i = 0; i < N_ITER; i++) {
35 if (i % 2 == 1)
36 free(ptrs[i]);
37 }
38
39 return 0;
40}
This page took 0.043147 seconds and 4 git commands to generate.