File: test_C_01.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 (41 lines) | stat: -rw-r--r-- 464 bytes parent folder | download | duplicates (3)
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static char * mkstr(char * s) { return strcpy((char*)malloc(strlen(s)+1), s); }

void f() { mkstr("asdfasdf"); }

void g()
{
  int i;
  char * a[100];

  for(i=0; i<100; i++)
    a[i] = mkstr("in f");
  
  free(a[2]);
  free(a[0]);
}

int
main()
{
  char * a = mkstr("Hallo"), *b;

  (void) mkstr("Test");

  f();

  b = mkstr("Test");

  g();

  a[6]=0;

  free(b);
  free(a);

  exit(0);
  return 1;
}