| 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; |
| 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; |
| 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) |
| 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; |
| 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; |