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 2.9 by schorsch, Sat Oct 23 18:55:52 2004 UTC vs.
Revision 2.10 by greg, Sat Apr 12 01:43:53 2025 UTC

# Line 17 | Line 17 | static const char      RCSid[] = "$Id$";
17  
18   #include "rtmisc.h"
19  
20 #ifndef  MBLKSIZ
21 #define  MBLKSIZ        16376           /* size of memory allocation block */
22 #endif
23 #define  WASTEFRAC      12              /* don't waste more than a fraction */
20   #ifndef  ALIGNT
21   #define  ALIGNT         double          /* type for alignment */
22   #endif
23   #define  BYTES_WORD     sizeof(ALIGNT)
24  
25 + #ifndef  MBLKSIZ                        /* size of memory allocation block */
26 + #define  MBLKSIZ        ((1<<15)-BYTES_WORD)
27 + #endif
28 + #define  WASTEFRAC      12              /* don't waste more than a fraction */
29 +
30   static char  *bposition = NULL;
31   static size_t  nremain = 0;
32  
32
33   void *
34 < bmalloc(                /* allocate a block of n bytes */
35 < register size_t  n
34 > bmalloc(                /* quickly allocate a block of n bytes */
35 > size_t  n
36   )
37   {
38 <        if (n > nremain && (n > MBLKSIZ || nremain > MBLKSIZ/WASTEFRAC))
38 >        if ((n > nremain) & ((n > MBLKSIZ) | (nremain > MBLKSIZ/WASTEFRAC)))
39                  return(malloc(n));                      /* too big */
40  
41 <        n = (n+(BYTES_WORD-1))&~(BYTES_WORD-1);         /* word align */
41 >        n = (n+(BYTES_WORD-1)) & ~(BYTES_WORD-1);       /* word align */
42  
43          if (n > nremain && (bposition = malloc(nremain = MBLKSIZ)) == NULL) {
44                  nremain = 0;
# Line 49 | Line 49 | register size_t  n
49          return(bposition - n);
50   }
51  
52
52   void
53 < bfree(                  /* free random memory */
54 < register void   *pp,
55 < register size_t n
53 > bfree(                  /* free some memory; anything in process space */
54 > void    *pp,
55 > size_t  n
56   )
57   {
58 <        register char *p = pp;
59 <        register size_t bsiz;
58 >        char *p = pp;
59 >        size_t  bsiz;
60                                          /* check alignment */
61          bsiz = BYTES_WORD - ((size_t)p&(BYTES_WORD-1));
62          if (bsiz < BYTES_WORD) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines