home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / rconfig.lha / RConfig_v1.1 / tests / 4b / test4b.c < prev   
C/C++ Source or Header  |  1992-09-12  |  722b  |  37 lines

  1. /*
  2.  * RConfig Validation Suite by Anthon Pang, Omni Communications Products
  3.  *
  4.  * Object Code: risky alloca
  5.  * Assigned Test # 4b
  6.  * Requirements: rlib.h
  7.  * Desired Observation(s): Prints address of block allocated
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include "alloca.h"
  12.  
  13. void test(int t) {
  14.     char *p;
  15.     int x;
  16.  
  17.     /*
  18.      *  risky alloca() takes as its only parameter the size of the block
  19.      *    to allocate; it makes the bold assumption that register a5 is
  20.      *    used in the current procedure for a local stack frame
  21.      */
  22.  
  23.     p = (char*)alloca(t);
  24.  
  25.     if (p==NULL) {
  26.         printf("Unable to alloca()\n");
  27.         return;
  28.     }
  29.         
  30.     printf("%ld\n", p);
  31. }
  32.  
  33. main() {
  34.     test(16384);
  35.     puts("Done.\n");
  36. }
  37.