ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/ealloc.c
(Generate patch)

Comparing ray/src/common/ealloc.c (file contents):
Revision 2.1 by greg, Tue Nov 12 16:54:23 1991 UTC vs.
Revision 2.7 by schorsch, Mon Oct 27 10:19:31 2003 UTC

# Line 1 | Line 1
1 /* Copyright 1988 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  ealloc.c - memory routines which call quit on error.
6   */
7  
8 + #include "copyright.h"
9  
10 +
11   #include  <stdio.h>
12 + #include  <stdlib.h>
13  
14 + #include "rterror.h"
15  
16 < char  *malloc(), *realloc(), *emalloc(), *ecalloc(), *erealloc();
17 <
17 <
18 < char *
19 < emalloc(n)                      /* return pointer to n uninitialized bytes */
20 < unsigned  n;
16 > extern char *   /* return pointer to n uninitialized bytes */
17 > emalloc(unsigned int  n)
18   {
19          register char  *cp;
20          
21          if (n == 0)
22                  return(NULL);
23  
24 <        if ((cp = malloc(n)) != NULL)
24 >        if ((cp = (char *)malloc(n)) != NULL)
25                  return(cp);
26  
27          eputs("Out of memory in emalloc\n");
# Line 32 | Line 29 | unsigned  n;
29   }
30  
31  
32 < char *
33 < ecalloc(ne, es)                 /* return pointer to initialized memory */
37 < register unsigned  ne;
38 < unsigned  es;
32 > extern char *                   /* return pointer to initialized memory */
33 > ecalloc(register unsigned int ne, unsigned int es)
34   {
35          register char  *cp;
36          
# Line 43 | Line 38 | unsigned  es;
38          if (ne == 0)
39                  return(NULL);
40  
41 <        if ((cp = malloc(ne)) == NULL) {
41 >        if ((cp = (char *)malloc(ne)) == NULL) {
42                  eputs("Out of memory in ecalloc\n");
43                  quit(1);
44          }
# Line 54 | Line 49 | unsigned  es;
49   }
50  
51  
52 < char *
53 < erealloc(cp, n)                 /* reallocate cp to size n */
59 < register char  *cp;
60 < unsigned  n;
52 > extern char *                   /* reallocate cp to size n */
53 > erealloc(register char  *cp, unsigned int  n)
54   {
55          if (n == 0) {
56                  if (cp != NULL)
57 <                        free(cp);
57 >                        free((void *)cp);
58                  return(NULL);
59          }
60  
61          if (cp == NULL)
62 <                cp = malloc(n);
62 >                cp = (char *)malloc(n);
63          else
64 <                cp = realloc(cp, n);
64 >                cp = (char *)realloc((void *)cp, n);
65  
66          if (cp != NULL)
67                  return(cp);
# Line 78 | Line 71 | unsigned  n;
71   }
72  
73  
74 < efree(cp)                       /* free memory allocated by above */
75 < char  *cp;
74 > extern void                     /* free memory allocated by above */
75 > efree(char  *cp)
76   {
77 <        free(cp);
77 >        free((void *)cp);
78   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines