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 2.6 by greg, Fri Sep 4 09:57:43 1992 UTC vs.
Revision 2.7 by greg, Fri Sep 4 18:36:05 1992 UTC

# Line 26 | Line 26 | static char SCCSid[] = "$SunId$ LBL";
26  
27   extern int      errno;
28  
29 + #ifndef  BSD
30 + #define  bcopy(s,d,n)           (void)memcpy(d,s,n)
31 + #define  bzero(d,n)             (void)memset(d,0,n)
32 + extern char  *memcpy(), *memset();
33 + #endif
34 +
35   #ifdef MSTATS
36   #include  <stdio.h>
37   static unsigned b_nsbrked = 0;
# Line 169 | Line 175 | unsigned       *np;
175                          big->siz = 0;           /* remove from table */
176                          return(big->ptr);       /* return it */
177                  }
178 <                if (mtablen(big) < tablen+1) {
178 >                if (mtablen(big) <= tablen) {
179                          *np = 0;                /* cannot grow table */
180                          return(NULL);           /* report failure */
181                  }
# Line 179 | Line 185 | unsigned       *np;
185                  cptab.ptr = big->ptr;
186                  cptab.siz = big->siz;
187                  big->siz = 0;                   /* clear and copy */
182 #ifdef BSD
188                  bcopy((char *)tab, (char *)(mtab(&cptab)+1),
189                                  tablen*sizeof(struct mblk));
190                  bzero((char *)(mtab(&cptab)+tablen+1),
191                          (mtablen(&cptab)-tablen-1)*sizeof(struct mblk));
187 #else
188                (void)memcpy((char *)(mtab(&cptab)+1), (char *)tab,
189                                tablen*sizeof(struct mblk));
190                memset((char *)(mtab(&cptab)+tablen+1), 0,
191                        (mtablen(&cptab)-tablen-1)*sizeof(struct mblk));
192 #endif
192          }                       /* next round */
193   }
194   #endif          /* MCOMP */
# Line 380 | Line 379 | unsigned       n;
379          if ((p = malloc(n)) == NULL)
380                  return(n<=on ? op : NULL);
381          if (on) {
383 #ifdef  BSD
382                  bcopy(op, p, n>on ? on : n);
385 #else
386                (void)memcpy(p, op, n>on ? on : n);
387 #endif
383                  free(op);
384          }
385          return(p);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines