--- ray/src/common/ealloc.c 2003/07/30 10:11:06 2.6 +++ 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.6 2003/07/30 10:11:06 schorsch 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. @@ -12,25 +12,27 @@ static const char RCSid[] = "$Id: ealloc.c,v 2.6 2003/ #include #include "rterror.h" +#include "rtmisc.h" -char * /* return pointer to n uninitialized bytes */ -emalloc(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 * /* return pointer to initialized memory */ -ecalloc(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; @@ -38,7 +40,7 @@ ecalloc(register unsigned int ne, 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); } @@ -49,30 +51,31 @@ ecalloc(register unsigned int ne, unsigned int es) } -char * /* reallocate cp to size n */ -erealloc(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) - free((void *)cp); + free(cp); return(NULL); } 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 /* free memory allocated by above */ -efree(char *cp) +extern void /* free memory allocated by above */ +efree(void *cp) { - free((void *)cp); + free(cp); }