File: test_C_17.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 (46 lines) | stat: -rw-r--r-- 708 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
/* This is mainly a test for logpid
 */

#include <stdlib.h>
#include <stdio.h>

#define NUM_PRG_TO_START 9

int main(int argc, char ** argv)
{
  int n;
  char buffer[20];
  char * leak, * no_leak;

  if(argc == 1)
    {
      n = NUM_PRG_TO_START;
      printf("  started  0");
    }
  else
    {
      n = atoi(argv[1]);
      printf("%d", NUM_PRG_TO_START - n);
    }

  fflush(stdout);

  leak = (char*) malloc(4711);
  no_leak = (char*) malloc(42);

  if(n > 0)
    {
      sprintf(buffer, "%s %d", argv[0], n - 1);
      system(buffer);
    }
  else printf("\n  finished  ");

  free(no_leak);

  printf("%d", n);
  if(n == NUM_PRG_TO_START) printf("\n");
  fflush(stdout);

  exit(0);
  return 1;
}