BSD 4_4 development
[unix-history] / usr / src / contrib / mprof / test1.c
CommitLineData
5718e5f3
C
1#include <stdio.h>
2
3struct tstruct {
4 char c;
5 int i;
6 float f;
7};
8
9extern char *malloc();
10extern char *valloc();
11extern char *realloc();
12extern char *calloc();
13extern char *memalign();
14extern long random();
15
16int
17main()
18{
19 int i;
20 char *c;
21/*
22 extern int keeping_leaks;
23 keeping_leaks = 0;
24*/
25 for (i = 0; i < 50; i++) {
26 c = memalign(32, 105);
27 if (i == 0) {
28 printf("memalign c = 0x%x\n", (int) c);
29 }
30 c = valloc(1345);
31 if (i == 0) {
32 printf("valloc c = 0x%x\n", (int) c);
33 }
34 c = malloc(sizeof(struct tstruct));
35 c = realloc(c, 2 * sizeof(struct tstruct));
36 free(c);
37 c = calloc(1, sizeof(struct tstruct));
38 c = realloc(c, sizeof(struct tstruct) / 2);
39 free(c);
40 c = malloc(random() % 57);
41 free(c);
42 c = calloc(1, random() % 57);
43 if (i % 2) {
44 free(c);
45 }
46 }
47 exit(0);
48}
49