--- ray/src/common/bmalloc.c 1990/09/25 18:56:04 1.1 +++ ray/src/common/bmalloc.c 1990/09/25 19:37:15 1.2 @@ -5,13 +5,17 @@ static char SCCSid[] = "$SunId$ LBL"; #endif /* - * Simple memory allocation without overhead + * Basic memory allocation w/o overhead. + * Calls malloc(3) for big requests. * */ +#define NULL 0 + #ifndef MBLKSIZ #define MBLKSIZ 16376 /* size of memory allocation block */ #endif +#define WASTEFRAC 4 /* don't waste more than this */ #ifndef ALIGN #define ALIGN int /* type for alignment */ #endif @@ -22,11 +26,12 @@ char * bmalloc(n) /* allocate a block of n bytes, no refunds */ register unsigned n; { + extern char *malloc(); static char *bpos = NULL; static unsigned nrem = 0; - if (n > MBLKSIZ/2) /* too big for me */ - return(malloc(n)); + if (n > nrem && (n > MBLKSIZ || nrem > MBLKSIZ/WASTEFRAC)) + return(malloc(n)); /* too big */ n = (n+(BYTES_WORD-1))&~(BYTES_WORD-1); /* word align */