312
|
1 #include <alloca.h>
|
17
|
2
|
172
|
3 int asize = 100;
|
|
4
|
|
5 int f(int i,int j,int k,int *l);
|
|
6 int g();
|
313
|
7 int f1(int i,int j,int *l,int k);
|
|
8 int g1(int k);
|
|
9 void f2();
|
172
|
10
|
|
11 int
|
|
12 main()
|
|
13 {
|
|
14 int a[0] ;
|
315
|
15 for(asize=4;asize<64000;asize=asize*2+12) {
|
|
16 f2(1);
|
|
17 f2(0);
|
|
18 printf("%d %d\n",g(),f(0,1,2,a));
|
|
19 printf("%d %d\n",g1(100),f1(0,1,a,2));
|
|
20 }
|
172
|
21 return 0;
|
|
22 }
|
17
|
23
|
|
24 int
|
172
|
25 g()
|
17
|
26 {
|
172
|
27 int k = 0,i;
|
|
28
|
315
|
29 char *p = alloca(asize<100?100:asize);
|
172
|
30 for(i=0;i<100;i++) p[i]=i;
|
|
31 for(i=0;i<100;i++) k += p[i];
|
|
32 return k;
|
17
|
33 }
|
172
|
34
|
|
35 int
|
|
36 f(int i,int j,int k,int *l)
|
|
37 {
|
|
38 *l = 3;
|
|
39 if (i++ >20) return *l;
|
|
40 return f(i,j,k,(int*)alloca(asize));
|
|
41 }
|
313
|
42
|
|
43 int
|
|
44 g1(int k)
|
|
45 {
|
|
46 int i;
|
|
47
|
315
|
48 char *p = ((char *)alloca(asize>100?asize:100))+k;
|
313
|
49 p -= k;
|
|
50 for(i=0;i<100;i++) p[i]=i;
|
|
51 for(i=0;i<100;i++) k += p[i];
|
|
52 return k;
|
|
53 }
|
|
54
|
|
55 int
|
|
56 f1(int i,int j,int *l,int k)
|
|
57 {
|
|
58 // printf("f1 &i=%x &k=%x\n",&i,&k);
|
|
59 // printf("f1 i=%d j=%d *l=%0x k=%d\n",i,j,l,k);
|
|
60 *l = 3;
|
|
61 printf("f1 i=%d j=%d *l=%0x k=%d\n",i,j,*l,k);
|
|
62 if (i++ >20) return *l;
|
|
63 return f1(i,j,(int*)alloca(asize),k);
|
|
64 }
|
|
65
|
|
66 void
|
|
67 f2(int k)
|
|
68 {
|
|
69 int *l;
|
|
70 if (k==1)
|
|
71 l = alloca(asize);
|
|
72 else
|
|
73 l = 0;
|
|
74 printf("f2: %0x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
|
|
75 // l,
|
|
76 0,
|
|
77 0,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
|
|
78 );
|
|
79 }
|
|
80
|