home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 125.img / PRO-C4.ZIP / BENCH1.ZIP / BENCH / ALLOC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-28  |  1.2 KB  |  58 lines

  1. /* ==( bench/alloc.c )== */
  2.  
  3. /* ----------------------------------------------- */
  4. /* Pro-C - Copyright (C) 1988, 1989 Vestronix Inc. */
  5. /* Modification to this source is not supported    */
  6. /* by Vestronix Inc.                               */
  7. /*            All Rights Reserved                  */
  8. /* ----------------------------------------------- */
  9. /* Written   Nig   1-Jan-87                        */
  10. /* Modified  Geo   4-Oct-89  See comments below    */
  11. /* ----------------------------------------------- */
  12. /* %W%  (%H% %T%) */
  13.  
  14. /*
  15.  *  Modifications
  16.  *
  17.  *   4-Nov-89  Geo - V2 version
  18.  *  25-Oct-89  Geo - 1.32 Merge
  19. */
  20.  
  21. /* Allocate a chunk of memory */
  22.  
  23. # include <stdio.h>
  24. # include <bench.h>
  25.  
  26. /*
  27.  * standard memory allocation routine, if MDEBUG is defined then the 
  28.  * debugging version palloc is switched in.
  29. */
  30. # ifndef MDEBUG
  31. char *alloc(size)
  32. unsigned size;
  33. {
  34.     char *ptr;
  35.  
  36. # ifdef DEBUGI
  37. /*
  38.     if (size > 5000)
  39.     {
  40.         fprintf(stderr, "\nAlloc [%u]\n", size); fflush(stderr);
  41.         getchar();
  42.     }
  43. */
  44. # endif
  45.  
  46.     ptr = calloc(size, sizeof(char));
  47.  
  48.     if (ptr == NULL)
  49.     {
  50.         fprintf(stderr, "\nOut of memory"); fflush(stderr);
  51.         exit(-1);
  52.     }
  53.     return ptr;
  54. }
  55.  
  56. # endif
  57.  
  58.