--- ray/src/common/ealloc.c 1991/11/12 16:54:23 2.1 +++ ray/src/common/ealloc.c 2003/10/27 10:19:31 2.7 @@ -1,30 +1,27 @@ -/* Copyright 1988 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ealloc.c,v 2.7 2003/10/27 10:19:31 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; +extern char * /* return pointer to n uninitialized bytes */ +emalloc(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,10 +29,8 @@ unsigned n; } -char * -ecalloc(ne, es) /* return pointer to initialized memory */ -register unsigned ne; -unsigned es; +extern char * /* return pointer to initialized memory */ +ecalloc(register unsigned int ne, unsigned int es) { register char *cp; @@ -43,7 +38,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); } @@ -54,21 +49,19 @@ unsigned es; } -char * -erealloc(cp, n) /* reallocate cp to size n */ -register char *cp; -unsigned n; +extern char * /* reallocate cp to size n */ +erealloc(register char *cp, 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); @@ -78,8 +71,8 @@ unsigned n; } -efree(cp) /* free memory allocated by above */ -char *cp; +extern void /* free memory allocated by above */ +efree(char *cp) { - free(cp); + free((void *)cp); }