1
/* $Id: alloca.c,v 1.1 2007/07/01 06:16:40 dmix Exp $ */
8
#define elemof(v) (sizeof(v) / sizeof((v)[0]))
10
/* A few of alloca() calls in the one function. */
11
void test_few_alloca (void)
16
/* Allocate and fill each block with sizes: 1 .. elemof(p) */
17
for (n = 1; n < (int)elemof(p); n++) {
19
memset (p[n-1], n, n);
22
/* Check that there is no overlapping. */
23
for (n = 1; n < (int)elemof(p); n++) {
24
for (i = 0; i < n; i++)
30
/* Variable size array and alloca() together. */
31
void test_with_var_array (int n)
37
/* Fill variable size array. */
40
/* Allocate and fill the second array. */
44
/* Refill the first array. */
45
for (i = 0; i < n; i++) s[i] += 1;
52
/* Increment the each element of buf[].
53
The second argument is the number of elements. */
54
void inc_array (unsigned char *buf, ...)
63
for (i = 0; i < n; i++) buf[i] += 1;
66
/* Check the compatibility with call of function, where arguments are
67
allocated in the stack. */
68
void test_with_var_args (int n)
73
/* Allocate and fill. */
77
/* Args are placed in stack. */
80
/* Check the result. */
81
for (i = 0; i < n; i++) {
90
test_with_var_array (10);
91
test_with_var_args (20);