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

Comparing ray/src/common/malloc.c (file contents):
Revision 1.9 by greg, Wed Oct 3 21:01:59 1990 UTC vs.
Revision 1.10 by greg, Tue Nov 13 14:39:05 1990 UTC

# Line 23 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23  
24   #ifdef MSTATS
25   #include  <stdio.h>
26
26   static unsigned b_nalloced = 0;
27   static unsigned b_nfreed = 0;
28   static unsigned b_nscrounged = 0;
# Line 56 | Line 55 | typedef union m_head {
55  
56   static M_HEAD   *free_list[NBUCKETS];
57  
58 + static char     DUMMYLOC[BYTES_WORD];
59  
60 +
61   char *
62   mscrounge(np)           /* search free lists to satisfy request */
63   register unsigned       *np;
# Line 171 | Line 172 | unsigned       n;
172          register M_HEAD *mp;
173          register int    bucket;
174          register unsigned       bsiz;
175 +                                        /* don't return NULL on 0 request */
176 +        if (n == 0)
177 +                return(DUMMYLOC);
178                                          /* find first bucket that fits */
179          for (bucket = FIRSTBUCKET, bsiz = 1<<FIRSTBUCKET;
180                          bucket < NBUCKETS; bucket++, bsiz <<= 1)
# Line 205 | Line 209 | unsigned       n;
209          char    *p;
210          register unsigned       on;
211                                          /* get old size */
212 <        if (op != NULL)
212 >        if (op != NULL && op != DUMMYLOC)
213                  on = 1 << ((M_HEAD *)op-1)->bucket;
214          else
215                  on = 0;
# Line 229 | Line 233 | char   *p;
233          register M_HEAD *mp;
234          register int    bucket;
235  
236 <        if (p == NULL)
236 >        if (p == NULL || p == DUMMYLOC)
237                  return;
238          mp = (M_HEAD *)p - 1;
239          bucket = mp->bucket;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines