home *** CD-ROM | disk | FTP | other *** search
/ MegaDoom Add-On 3 / MEGADOOM3.iso / editor / bsp12x / funcs.c < prev    next >
Text File  |  1994-10-26  |  985b  |  39 lines

  1. /*- FUNCS.C ----------------------------------------------------------------*/
  2. /*- terminate the program reporting an error -------------------------------*/
  3.  
  4. void ProgError( char *errstr, ...)
  5. {
  6.    va_list args;
  7.  
  8.    va_start( args, errstr);
  9.    printf( "\nProgram Error: *** ");
  10.    vprintf( errstr, args);
  11.    printf( " ***\n");
  12.    va_end( args);
  13.    exit( 5);
  14. }
  15.  
  16. /*- allocate memory with error checking ------------------------------------*/
  17.  
  18. void *GetMemory( size_t size)
  19. {
  20.    void *ret = malloc( size);
  21.    if (!ret)
  22.       ProgError( "out of memory (cannot allocate %u bytes)", size);
  23.    return ret;
  24. }
  25.  
  26. /*- reallocate memory with error checking ----------------------------------*/
  27.  
  28. void *ResizeMemory( void *old, size_t size)
  29. {
  30.    void *ret = realloc( old, size);
  31.    if (!ret)
  32.       ProgError( "out of memory (cannot reallocate %u bytes)", size);
  33.    return ret;
  34. }
  35.  
  36.  
  37. /*--------------------------------------------------------------------------*/
  38.  
  39.