/*- FUNCS.C ----------------------------------------------------------------*/ /*- terminate the program reporting an error -------------------------------*/ void ProgError( char *errstr, ...) { va_list args; va_start( args, errstr); printf( "\nProgram Error: *** "); vprintf( errstr, args); printf( " ***\n"); va_end( args); exit( 5); } /*- allocate memory with error checking ------------------------------------*/ void *GetMemory( size_t size) { void *ret = malloc( size); if (!ret) ProgError( "out of memory (cannot allocate %u bytes)", size); return ret; } /*- reallocate memory with error checking ----------------------------------*/ void *ResizeMemory( void *old, size_t size) { void *ret = realloc( old, size); if (!ret) ProgError( "out of memory (cannot reallocate %u bytes)", size); return ret; } /*--------------------------------------------------------------------------*/