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.4 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 2.8 by schorsch, Sun Oct 3 20:48:53 2004 UTC

# Line 15 | Line 15 | static const char      RCSid[] = "$Id$";
15  
16   #include <stdlib.h>
17  
18 + #include "rtmisc.h"
19 +
20   #ifndef  MBLKSIZ
21   #define  MBLKSIZ        16376           /* size of memory allocation block */
22   #endif
# Line 25 | Line 27 | static const char      RCSid[] = "$Id$";
27   #define  BYTES_WORD     sizeof(ALIGNT)
28  
29   static char  *bposition = NULL;
30 < static unsigned int  nremain = 0;
30 > static size_t  nremain = 0;
31  
32  
33 < char *
34 < bmalloc(n)              /* allocate a block of n bytes */
35 < register unsigned int  n;
33 > void *
34 > bmalloc(                /* allocate a block of n bytes */
35 > register size_t  n
36 > )
37   {
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 */
42  
43 <        if (n > nremain && (bposition = (char *)malloc(nremain = MBLKSIZ)) == NULL) {
43 >        if (n > nremain && (bposition = malloc(nremain = MBLKSIZ)) == NULL) {
44                  nremain = 0;
45                  return(NULL);
46          }
# Line 48 | Line 51 | register unsigned int  n;
51  
52  
53   void
54 < bfree(p, n)                     /* free random memory */
55 < register char   *p;
56 < register unsigned int   n;
54 > bfree(                  /* free random memory */
55 > register void   *p,
56 > register size_t n
57 > )
58   {
59 <        register unsigned int   bsiz;
59 >        register size_t bsiz;
60                                          /* check alignment */
61 <        bsiz = BYTES_WORD - ((unsigned int)p&(BYTES_WORD-1));
61 >        bsiz = BYTES_WORD - ((size_t)p&(BYTES_WORD-1));
62          if (bsiz < BYTES_WORD) {
63                  p += bsiz;
64                  n -= bsiz;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines