File: test_C_18.c

package info (click to toggle)
ccmalloc 0.4.0-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 488 kB
  • ctags: 446
  • sloc: ansic: 4,493; sh: 523; makefile: 105; cpp: 89
file content (72 lines) | stat: -rw-r--r-- 925 bytes parent folder | download | duplicates (6)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdlib.h>

int num()
{
  int res;

  res = rand();
  if(res < 0) res = -res;
  res %= 10;

  return res;
}

void i()
{
  (void) malloc(10);
}

void j()
{
  (void) malloc(11);
}

void h()
{
  if(rand() % 2 == 0) i();
  else j();
}

void g()
{
  switch(num())
    {
      case 0: h(); break;
      case 1: i(); break;
      case 2: j(); break;
      case 3: h(); break;
      case 4: i(); break;
      case 5: j(); break;
      case 6: h(); break;
      case 7: i(); break;
      case 8: j(); break;
      default: h(); break;
    }
}

void f()
{
  switch(num())
    {
      case 0: g(); break;
      case 1: h(); break;
      case 2: i(); break;
      case 3: j(); break;
      case 4: g(); break;
      case 5: h(); break;
      case 6: i(); break;
      case 7: j(); break;
      case 8: g(); break;
      default: h(); break;
    }
}

int main()
{
  int i;

  for(i=0; i<1000; i++) f();

  exit(0);
  return 0;
}