home *** CD-ROM | disk | FTP | other *** search
/ The Complete Doom Accessory Pack 2 / TheCompleteDoomAccessoryPackVolumeII.iso / editors / bspwin / funcs.c < prev    next >
C/C++ Source or Header  |  1994-05-24  |  1KB  |  46 lines

  1. /*- FUNCS.C ----------------------------------------------------------------*/
  2. /*- terminate the program reporting an error -------------------------------*/
  3. #include "prottype.h"
  4.  
  5. void ProgError( char *errstr, ...)
  6. {
  7.    va_list args;
  8.  
  9.    va_start( args, errstr);
  10.    printf( "\nProgram Error: *** ");
  11.    vprintf( errstr, args);
  12.    printf( " ***\n");
  13.    va_end( args);
  14.    ExitProgram(5);
  15. }
  16.  
  17. /*- allocate memory with error checking ------------------------------------
  18.  I replaced original malloc and realloc calls with their far
  19.  counterparts because of 'Out of memory' error I got under Windows on large
  20.  WAD -  after this replacement all seemed to work fine - Alex Korobka        */
  21.  
  22. #if defined(__SMALL__) || defined(__MEDIUM__)
  23.     #error This program requires memory model with FAR DATA pointers
  24. #endif
  25.  
  26. void *GetMemory(size_t size)
  27. {
  28.    void *ret = farmalloc( size);
  29.    if (!ret)
  30.       ProgError( "Out of memory (cannot allocate %u bytes)", size);
  31.    return ret;
  32. }
  33.  
  34. /*- reallocate memory with error checking ----------------------------------*/
  35.  
  36. void *ResizeMemory( void *old, size_t size)
  37. {
  38.    void *ret = farrealloc( old, size);
  39.    if (!ret)
  40.       ProgError( "Out of memory (cannot reallocate %u bytes)", size);
  41.    return ret;
  42. }
  43.  
  44. /*--------------------------------------------------------------------------*/
  45.  
  46.