1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Fast malloc for memory hogs and VM environments. |
6 |
|
* Performs a minimum of searching through free lists. |
19 |
|
* Greg Ward Lawrence Berkeley Laboratory |
20 |
|
*/ |
21 |
|
|
22 |
+ |
#include "copyright.h" |
23 |
+ |
|
24 |
|
#include <errno.h> |
25 |
|
|
26 |
|
#ifndef BSD |
27 |
|
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
28 |
|
#define bzero(d,n) (void)memset(d,0,n) |
30 |
– |
extern char *memcpy(), *memset(); |
29 |
|
#endif |
30 |
|
|
31 |
|
#ifdef MSTATS |
42 |
|
#define NULL 0 |
43 |
|
#endif |
44 |
|
|
45 |
< |
#ifndef ALIGN |
46 |
< |
#define ALIGN int /* align type */ |
45 |
> |
#ifndef ALIGNT |
46 |
> |
#define ALIGNT int /* align type */ |
47 |
|
#endif |
48 |
< |
#define BYTES_WORD sizeof(ALIGN) |
48 |
> |
#define BYTES_WORD sizeof(ALIGNT) |
49 |
|
|
50 |
|
#ifndef MAXINCR |
51 |
|
#define MAXINCR (1<<16) /* largest sbrk(2) increment */ |
57 |
|
short magic; |
58 |
|
short bucket; |
59 |
|
} a; |
60 |
< |
ALIGN dummy; |
60 |
> |
ALIGNT dummy; |
61 |
|
} M_HEAD; |
62 |
|
|
63 |
|
#define MAGIC 0x1a2 /* magic number for allocated memory */ |
67 |
|
|
68 |
|
static M_HEAD *free_list[NBUCKETS]; |
69 |
|
|
70 |
< |
static ALIGN dummy_mem; |
70 |
> |
static ALIGNT dummy_mem; |
71 |
|
|
72 |
|
static char *memlim[2]; |
73 |
|
|
302 |
|
register int bucket; |
303 |
|
register unsigned bsiz; |
304 |
|
|
305 |
< |
if (n < 1<<FIRSTBUCKET) |
305 |
> |
if (n < 1<<FIRSTBUCKET || p == NULL) |
306 |
|
return; |
307 |
|
#ifdef MSTATS |
308 |
|
b_nfreed += n; |