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

Comparing ray/src/common/bmalloc.c (file contents):
Revision 1.1 by greg, Tue Sep 25 18:56:04 1990 UTC vs.
Revision 1.2 by greg, Tue Sep 25 19:37:15 1990 UTC

# Line 5 | Line 5 | static char SCCSid[] = "$SunId$ LBL";
5   #endif
6  
7   /*
8 < * Simple memory allocation without overhead
8 > * Basic memory allocation w/o overhead.
9 > * Calls malloc(3) for big requests.
10   *
11   */
12  
13 + #define  NULL           0
14 +
15   #ifndef  MBLKSIZ
16   #define  MBLKSIZ        16376           /* size of memory allocation block */
17   #endif
18 + #define  WASTEFRAC      4               /* don't waste more than this */
19   #ifndef  ALIGN
20   #define  ALIGN          int             /* type for alignment */
21   #endif
# Line 22 | Line 26 | char *
26   bmalloc(n)              /* allocate a block of n bytes, no refunds */
27   register unsigned  n;
28   {
29 +        extern char  *malloc();
30          static char  *bpos = NULL;
31          static unsigned  nrem = 0;
32  
33 <        if (n > MBLKSIZ/2)                      /* too big for me */
34 <                return(malloc(n));
33 >        if (n > nrem && (n > MBLKSIZ || nrem > MBLKSIZ/WASTEFRAC))
34 >                return(malloc(n));                      /* too big */
35  
36          n = (n+(BYTES_WORD-1))&~(BYTES_WORD-1);         /* word align */
37  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines