Deleted Added
sdiff udiff text old ( 42453 ) new ( 42957 )
full compact
1/*
2 * Copyright (c) 1987, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
34 * $Id: kern_malloc.c,v 1.50 1999/01/08 17:31:09 eivind Exp $
35 */
36
37#include "opt_vm.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#define MALLOC_INSTANTIATE

--- 53 unchanged lines hidden (view full) ---

96};
97#else /* !INVARIANTS */
98struct freelist {
99 caddr_t next;
100};
101#endif /* INVARIANTS */
102
103/*
104 * Allocate a block of memory
105 */
106void *
107malloc(size, type, flags)
108 unsigned long size;
109 struct malloc_type *type;
110 int flags;
111{
112 register struct kmembuckets *kbp;

--- 4 unchanged lines hidden (view full) ---

117 caddr_t va, cp, savedlist;
118#ifdef INVARIANTS
119 long *end, *lp;
120 int copysize;
121 char *savedtype;
122#endif
123 register struct malloc_type *ksp = type;
124
125 if (!type->ks_next)
126 malloc_init(type);
127
128 indx = BUCKETINDX(size);
129 kbp = &bucket[indx];
130 s = splmem();
131 while (ksp->ks_memuse >= ksp->ks_limit) {
132 if (flags & M_NOWAIT) {
133 splx(s);
134 return ((void *) NULL);
135 }
136 if (ksp->ks_limblocks < 65535)
137 ksp->ks_limblocks++;
138 tsleep((caddr_t)ksp, PSWP+2, type->ks_shortdesc, 0);
139 }

--- 94 unchanged lines hidden (view full) ---

234 ksp->ks_calls++;
235 if (ksp->ks_memuse > ksp->ks_maxused)
236 ksp->ks_maxused = ksp->ks_memuse;
237 splx(s);
238 return ((void *) va);
239}
240
241/*
242 * Free a block of memory allocated by malloc.
243 */
244void
245free(addr, type)
246 void *addr;
247 struct malloc_type *type;
248{
249 register struct kmembuckets *kbp;
250 register struct kmemusage *kup;

--- 225 unchanged lines hidden ---