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

Comparing ray/src/meta/palloc.c (file contents):
Revision 1.1 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 1.3 by schorsch, Mon Jul 21 22:30:18 2003 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9   #define  FBSIZE  72             /* size of malloc call */
10  
11  
12
13
14
12   #include  "meta.h"
13  
14  
18
19
20
15   extern int  maxalloc;           /* number of prims to allocate */
22
16   int  nalloc = 0;                /* number allocated so far */
17  
25
26
18   static PLIST  freelist = {NULL, NULL};
19  
20  
21 + static int morefree(void);
22  
23  
24   PRIMITIVE *
25 < palloc()                /* allocate a primitive */
25 > palloc(void)            /* allocate a primitive */
26  
27   {
28 < register PRIMITIVE  *p;
28 >    register PRIMITIVE  *p;
29  
30 < if (maxalloc > 0 && nalloc >= maxalloc)
31 <    return(NULL);
30 >    if (maxalloc > 0 && nalloc >= maxalloc)
31 >        return(NULL);
32  
33 < if ((p = pop(&freelist)) == NULL)
34 <    if (morefree())
35 <       p = pop(&freelist);
36 <    else {
37 <       sprintf(errmsg, "out of memory in palloc (nalloc = %d)", nalloc);
38 <       error(SYSTEM, errmsg);
39 <       }
33 >    if ((p = pop(&freelist)) == NULL) {
34 >        if (morefree())
35 >            p = pop(&freelist);
36 >        else {
37 >            sprintf(errmsg, "out of memory in palloc (nalloc = %d)", nalloc);
38 >            error(SYSTEM, errmsg);
39 >        }
40 >    }
41  
42 < nalloc++;
43 < return(p);
44 < }
42 >    nalloc++;
43 >    return(p);
44 > }
45  
46  
47  
48 <
49 <
50 < pfree(p)                /* free a primitive */
51 <
59 < register PRIMITIVE  *p;
60 <
48 > void
49 > pfree(          /* free a primitive */
50 > register PRIMITIVE  *p
51 > )
52   {
53  
54   if (p->args != NULL) {
# Line 71 | Line 62 | register PRIMITIVE  *p;
62  
63  
64  
65 <
66 < plfree(pl)              /* free a primitive list */
67 <
68 < register PLIST  *pl;
78 <
65 > void
66 > plfree(         /* free a primitive list */
67 > register PLIST  *pl
68 > )
69   {
70      register PRIMITIVE  *p;
71      
# Line 94 | Line 84 | register PLIST  *pl;
84      
85  
86  
97
98
87   static int
88 < morefree()              /* get more free space */
88 > morefree(void)          /* get more free space */
89  
90   {
91   register PRIMITIVE  *p;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines