--- ray/src/common/ealloc.c 2003/02/25 02:47:21 2.3 +++ ray/src/common/ealloc.c 2004/03/28 20:33:12 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ealloc.c,v 2.3 2003/02/25 02:47:21 greg Exp $"; +static const char RCSid[] = "$Id: ealloc.c,v 2.9 2004/03/28 20:33:12 schorsch Exp $"; #endif /* * ealloc.c - memory routines which call quit on error. @@ -11,28 +11,28 @@ static const char RCSid[] = "$Id: ealloc.c,v 2.3 2003/ #include #include +#include "rterror.h" +#include "rtmisc.h" -char * -emalloc(n) /* return pointer to n uninitialized bytes */ -unsigned int n; +extern void * /* return pointer to n uninitialized bytes */ +emalloc(size_t n) { - register char *cp; + register void *cp; if (n == 0) return(NULL); - if ((cp = (char *)malloc(n)) != NULL) + if ((cp = malloc(n)) != NULL) return(cp); eputs("Out of memory in emalloc\n"); quit(1); + return NULL; /* pro forma return */ } -char * -ecalloc(ne, es) /* return pointer to initialized memory */ -register unsigned int ne; -unsigned int es; +extern void * /* return pointer to initialized memory */ +ecalloc(register size_t ne, size_t es) { register char *cp; @@ -40,7 +40,7 @@ unsigned int es; if (ne == 0) return(NULL); - if ((cp = (char *)malloc(ne)) == NULL) { + if ((cp = malloc(ne)) == NULL) { eputs("Out of memory in ecalloc\n"); quit(1); } @@ -51,10 +51,8 @@ unsigned int es; } -char * -erealloc(cp, n) /* reallocate cp to size n */ -register char *cp; -unsigned int n; +extern void * /* reallocate cp to size n */ +erealloc(register void *cp, size_t n) { if (n == 0) { if (cp != NULL) @@ -63,21 +61,21 @@ unsigned int n; } if (cp == NULL) - cp = (char *)malloc(n); + cp = malloc(n); else - cp = (char *)realloc((void *)cp, n); + cp = realloc(cp, n); if (cp != NULL) return(cp); eputs("Out of memory in erealloc\n"); quit(1); + return NULL; /* pro forma return */ } -void -efree(cp) /* free memory allocated by above */ -char *cp; +extern void /* free memory allocated by above */ +efree(void *cp) { - free((char *)cp); + free(cp); }