home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <time.h>
- #include <stdio.h>
- #include <setjmp.h>
-
- #include "alloca.h"
-
- #define ASIZE 2048
- #define ACNT 64
-
- static int acnt, ajmp;
-
- static jmp_buf ajmb;
-
- static void
- allocatst (void)
- {
- int *b;
- register int i;
-
- srand (time (0));
-
- b = alloca (ASIZE);
-
- for (i = 0; i < (ASIZE >> 2); i++)
- b[i] = rand ();
-
- printf ("%x\t", b);
-
- b = alloca (ASIZE);
-
- for (i = 0; i < (ASIZE >> 2); i++)
- b[i] = rand ();
-
- printf ("%x\n", b);
-
- if (++acnt == ACNT)
- {
- if (ajmp)
- longjmp (ajmb, -1);
- else
- return;
- }
-
- allocatst ();
- }
-
- int
- main ()
- {
- acnt = 0, ajmp = 0;
- allocatst ();
-
- if (setjmp (ajmb))
- goto next;
-
- acnt = 0, ajmp = -1;
- allocatst ();
-
- next:acnt = 0, ajmp = 0;
- allocatst ();
-
- if (setjmp (ajmb))
- exit (0);
-
- acnt = 0, ajmp = -1;
- allocatst ();
- return 0;
- }
-