--- ray/src/common/ealloc.c 1989/02/02 13:53:40 1.2 +++ ray/src/common/ealloc.c 2003/02/25 02:47:21 2.3 @@ -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.3 2003/02/25 02:47:21 greg Exp $"; #endif - /* * ealloc.c - memory routines which call quit on error. */ +#include "copyright.h" + #include +#include -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"); @@ -34,8 +31,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; @@ -43,7 +40,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); } @@ -57,7 +54,7 @@ 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) @@ -66,9 +63,9 @@ unsigned n; } 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 +75,9 @@ unsigned n; } +void efree(cp) /* free memory allocated by above */ char *cp; { - free(cp); + free((char *)cp); }