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.2 by greg, Thu Feb 2 13:53:40 1989 UTC vs.
Revision 2.5 by schorsch, Thu Jul 17 09:21:29 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  
15 char  *malloc(), *realloc(), *emalloc(), *ecalloc(), *erealloc();
16
17
16   char *
17   emalloc(n)                      /* return pointer to n uninitialized bytes */
18 < unsigned  n;
18 > unsigned int  n;
19   {
20          register char  *cp;
21          
22          if (n == 0)
23                  return(NULL);
24  
25 <        if ((cp = malloc(n)) != NULL)
25 >        if ((cp = (char *)malloc(n)) != NULL)
26                  return(cp);
27  
28          eputs("Out of memory in emalloc\n");
# Line 34 | Line 32 | unsigned  n;
32  
33   char *
34   ecalloc(ne, es)                 /* return pointer to initialized memory */
35 < register unsigned  ne;
36 < unsigned  es;
35 > register unsigned int  ne;
36 > unsigned int  es;
37   {
38          register char  *cp;
39          
# Line 43 | Line 41 | unsigned  es;
41          if (ne == 0)
42                  return(NULL);
43  
44 <        if ((cp = malloc(ne)) == NULL) {
44 >        if ((cp = (char *)malloc(ne)) == NULL) {
45                  eputs("Out of memory in ecalloc\n");
46                  quit(1);
47          }
# Line 57 | Line 55 | unsigned  es;
55   char *
56   erealloc(cp, n)                 /* reallocate cp to size n */
57   register char  *cp;
58 < unsigned  n;
58 > unsigned int  n;
59   {
60          if (n == 0) {
61                  if (cp != NULL)
62 <                        free(cp);
62 >                        free((void *)cp);
63                  return(NULL);
64          }
65  
66          if (cp == NULL)
67 <                cp = malloc(n);
67 >                cp = (char *)malloc(n);
68          else
69 <                cp = realloc(cp, n);
69 >                cp = (char *)realloc((void *)cp, n);
70  
71          if (cp != NULL)
72                  return(cp);
# Line 78 | Line 76 | unsigned  n;
76   }
77  
78  
79 + void
80   efree(cp)                       /* free memory allocated by above */
81   char  *cp;
82   {
83 <        free(cp);
83 >        free((void *)cp);
84   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines