--- ray/src/common/ealloc.c 1989/02/02 10:34:30 1.1 +++ ray/src/common/ealloc.c 2003/07/17 09:21:29 2.5 @@ -1,28 +1,28 @@ -/* - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ealloc.c,v 2.5 2003/07/17 09:21:29 schorsch Exp $"; #endif +/* * ealloc.c - memory routines which call quit on error. */ +#include "copyright.h" + #include +#include +#include "rterror.h" -char *malloc(), *realloc(), *emalloc(), *ecalloc(), *erealloc(); - - char * emalloc(n) /* return pointer to n uninitialized bytes */ -unsigned n; +unsigned int n; { register char *cp; if (n == 0) return(NULL); - if ((cp = malloc(n)) != NULL) + if ((cp = (char *)malloc(n)) != NULL) return(cp); eputs("Out of memory in emalloc\n"); @@ -32,8 +32,8 @@ unsigned n; char * ecalloc(ne, es) /* return pointer to initialized memory */ -register unsigned ne; -unsigned es; +register unsigned int ne; +unsigned int es; { register char *cp; @@ -41,7 +41,7 @@ unsigned es; if (ne == 0) return(NULL); - if ((cp = malloc(ne)) == NULL) { + if ((cp = (char *)malloc(ne)) == NULL) { eputs("Out of memory in ecalloc\n"); quit(1); } @@ -55,18 +55,18 @@ unsigned es; char * erealloc(cp, n) /* reallocate cp to size n */ register char *cp; -unsigned n; +unsigned int n; { if (n == 0) { if (cp != NULL) - free(cp); + free((void *)cp); return(NULL); } if (cp == NULL) - cp = malloc(n); + cp = (char *)malloc(n); else - cp = realloc(cp, n); + cp = (char *)realloc((void *)cp, n); if (cp != NULL) return(cp); @@ -76,8 +76,9 @@ unsigned n; } +void efree(cp) /* free memory allocated by above */ char *cp; { - free(cp); + free((void *)cp); }