5 |
|
#endif |
6 |
|
|
7 |
|
/* |
8 |
< |
* Simple memory allocation without overhead |
8 |
> |
* Basic memory allocation w/o overhead. |
9 |
> |
* Calls malloc(3) for big requests. |
10 |
|
* |
11 |
|
*/ |
12 |
|
|
13 |
+ |
#define NULL 0 |
14 |
+ |
|
15 |
|
#ifndef MBLKSIZ |
16 |
|
#define MBLKSIZ 16376 /* size of memory allocation block */ |
17 |
|
#endif |
18 |
+ |
#define WASTEFRAC 4 /* don't waste more than this */ |
19 |
|
#ifndef ALIGN |
20 |
|
#define ALIGN int /* type for alignment */ |
21 |
|
#endif |
26 |
|
bmalloc(n) /* allocate a block of n bytes, no refunds */ |
27 |
|
register unsigned n; |
28 |
|
{ |
29 |
+ |
extern char *malloc(); |
30 |
|
static char *bpos = NULL; |
31 |
|
static unsigned nrem = 0; |
32 |
|
|
33 |
< |
if (n > MBLKSIZ/2) /* too big for me */ |
34 |
< |
return(malloc(n)); |
33 |
> |
if (n > nrem && (n > MBLKSIZ || nrem > MBLKSIZ/WASTEFRAC)) |
34 |
> |
return(malloc(n)); /* too big */ |
35 |
|
|
36 |
|
n = (n+(BYTES_WORD-1))&~(BYTES_WORD-1); /* word align */ |
37 |
|
|