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 1.1 by greg, Thu Feb 2 10:34:30 1989 UTC vs.
Revision 2.3 by greg, Tue Feb 25 02:47:21 2003 UTC

# Line 1 | Line 1
1 /*
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
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  
13 char  *malloc(), *realloc(), *emalloc(), *ecalloc(), *erealloc();
14
15
15   char *
16   emalloc(n)                      /* return pointer to n uninitialized bytes */
17 < unsigned  n;
17 > 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 31 | unsigned  n;
31  
32   char *
33   ecalloc(ne, es)                 /* return pointer to initialized memory */
34 < register unsigned  ne;
35 < unsigned  es;
34 > register unsigned int  ne;
35 > unsigned int  es;
36   {
37          register char  *cp;
38          
# Line 41 | Line 40 | unsigned  es;
40          if (ne == 0)
41                  return(NULL);
42  
43 <        if ((cp = malloc(ne)) == NULL) {
43 >        if ((cp = (char *)malloc(ne)) == NULL) {
44                  eputs("Out of memory in ecalloc\n");
45                  quit(1);
46          }
# Line 55 | Line 54 | unsigned  es;
54   char *
55   erealloc(cp, n)                 /* reallocate cp to size n */
56   register char  *cp;
57 < unsigned  n;
57 > unsigned int  n;
58   {
59          if (n == 0) {
60                  if (cp != NULL)
# Line 64 | Line 63 | unsigned  n;
63          }
64  
65          if (cp == NULL)
66 <                cp = malloc(n);
66 >                cp = (char *)malloc(n);
67          else
68 <                cp = realloc(cp, n);
68 >                cp = (char *)realloc((void *)cp, n);
69  
70          if (cp != NULL)
71                  return(cp);
# Line 76 | Line 75 | unsigned  n;
75   }
76  
77  
78 + void
79   efree(cp)                       /* free memory allocated by above */
80   char  *cp;
81   {
82 <        free(cp);
82 >        free((char *)cp);
83   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines