/************************************************************************* * *N vpfmalloc * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function allocates memory off of the heap and checks for * success. If not enough memory is available, this routine will abort * the program with an error message. Can be in graphics mode to call * this procedure, not a necessity. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * size <input> == (unsigned long) number of bytes to allocate. * return <output> == (void *) pointer to the allocated memory. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels April 1990 Original Version DOS Turbo C * Ronald Rozensky Sept 1991 check for no memory, graphics mode *E *************************************************************************/ void *vpfmalloc( unsigned long size ) { void *p; #ifdef __MSDOS__ p = farmalloc( size ); if (!p) { printf("Out of memory %ld %ld\n",size,farcoreleft()); getch(); if (graphic_mode()) closegraph(); exit(1); } #else p = malloc(size); if (!p) { printf("Out of memory %ld\n", size); exit(1); } #endif return p; }
void do_clg (void) { graphic_mode(); gclear(); gflush(); }