1 #include <stdio.h> 2 #include "fluctuate.h" 3 #if 0 4 #undef calloc 5 #undef realloc 6 #undef strtok 7 8 extern FILE *simlog; 9 10 #ifdef DMALLOC_FUNC_CHECK 11 #include "/usr/local/include/dmalloc.h" 12 #endif 13 14 15 /* Note that 'nelem' argument is long instead of size_t (even though it 16 should be size_t) to avoid having to make lots of changes to other code). 17 */ 18 19 void *E_calloc(long nelem, size_t size, char *CallerFile, int CallerLine) 20 { 21 void *vp; 22 23 if ((vp = calloc ((size_t)nelem, size)) != NULL) 24 return vp; 25 fprintf(ERRFILE, "calloc(%ld, %ld) failed, called from line %d in %s\n", 26 nelem, (long)size, CallerLine, CallerFile); 27 exit(1); 28 } 29 30 /* Note that 'nelem' argument is long instead of size_t (even though it 31 should be size_t) to avoid having to make lots of changes to other code). 32 */ 33 34 void *E_realloc(void *vp, long size, char *CallerFile, int CallerLine) 35 { 36 if ((vp = realloc (vp, (size_t)size)) != NULL) 37 return vp; 38 fprintf(ERRFILE, 39 "realloc(..., %ld) failed, called from line %d in %s\n", 40 (long)size, CallerLine, CallerFile); 41 exit(1); 42 } 43 44 45 FILE *Err_fopen(char *filename, char *mode, char *CallerFile, int CallerLine) 46 { 47 FILE *fp; 48 49 if ((fp = fopen(filename, mode)) != NULL) 50 return fp; 51 52 fprintf(ERRFILE, "fopen(%s, %s) failed, called from line %d in %s\n", 53 filename, mode, CallerLine, CallerFile); 54 exit(1); 55 } 56 57 char *E_strtok(char *newstring, const char *delimiters, char 58 *CallerFile, int CallerLine) 59 { 60 char *results; 61 62 if ((results = strtok(newstring,delimiters)) != NULL) 63 return(results); 64 65 fprintf(ERRFILE, "strtok failed, called from line %d in %s\n", 66 CallerLine, CallerFile); 67 fprintf(ERRFILE, 68 "This probably indicates a bad entry in the parmfile.\n"); 69 exit(1); 70 } 71 #endif 72