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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines