/*** * utility.c * * See utility.h * * $Id: utility.c 12567 2007-04-09 16:12:05Z mahoney $ ***/ #include #include #include "utility.h" void* safe_malloc(int size){ void* ptr = malloc(size); if (ptr==NULL){ // If the desired memory can't be allocated, exit(1); // then exit the program with an error. } return ptr; } char* int2string(int i){ char* string = (char*) safe_malloc(16); sprintf(string, "%i", i); return string; }