diff options
author | 2002-12-20 06:00:53 +0000 | |
---|---|---|
committer | 2002-12-20 06:00:53 +0000 | |
commit | 925e59ac150aeb0f9142eb58d73baef0a85415ea (patch) | |
tree | 4b711f6995b9e0062d0669a9a9db67b1c2eb788d | |
parent | user-defined stacks check is the same for grownups as for growndowns (diff) | |
download | wireguard-openbsd-925e59ac150aeb0f9142eb58d73baef0a85415ea.tar.xz wireguard-openbsd-925e59ac150aeb0f9142eb58d73baef0a85415ea.zip |
Add a special malloc type M_DEBUG.
If the kernel is compiled with MALLOC_DEBUG, M_DEBUG will force the allocation
to be done through malloc_debug.
-rw-r--r-- | sys/kern/kern_malloc_debug.c | 9 | ||||
-rw-r--r-- | sys/sys/malloc.h | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/sys/kern/kern_malloc_debug.c b/sys/kern/kern_malloc_debug.c index c31aa4adc96..beffe411edf 100644 --- a/sys/kern/kern_malloc_debug.c +++ b/sys/kern/kern_malloc_debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc_debug.c,v 1.20 2002/12/05 22:32:04 art Exp $ */ +/* $OpenBSD: kern_malloc_debug.c,v 1.21 2002/12/20 06:00:53 art Exp $ */ /* * Copyright (c) 1999, 2000 Artur Grabowski <art@openbsd.org> @@ -115,11 +115,11 @@ debug_malloc(unsigned long size, int type, int flags, void **addr) int s, wait = flags & M_NOWAIT; /* Careful not to compare unsigned long to int -1 */ - if ((type != debug_malloc_type && debug_malloc_type != 0) || + if (((type != debug_malloc_type && debug_malloc_type != 0) || (size != debug_malloc_size && debug_malloc_size != 0) || (debug_malloc_size_lo != -1 && size < debug_malloc_size_lo) || (debug_malloc_size_hi != -1 && size > debug_malloc_size_hi) || - !debug_malloc_initialized) + !debug_malloc_initialized) && type != M_DEBUG) return (0); /* XXX - fix later */ @@ -163,7 +163,8 @@ debug_free(void *addr, int type) vaddr_t va; int s; - if (type != debug_malloc_type && debug_malloc_type != 0) + if (type != debug_malloc_type && debug_malloc_type != 0 && + type != M_DEBUG) return (0); /* diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 2355be15970..c9eb7777466 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.h,v 1.62 2002/12/17 23:11:31 millert Exp $ */ +/* $OpenBSD: malloc.h,v 1.63 2002/12/20 06:00:53 art Exp $ */ /* $NetBSD: malloc.h,v 1.39 1998/07/12 19:52:01 augustss Exp $ */ /* @@ -65,7 +65,7 @@ #define M_FREE 0 /* should be on free list */ #define M_MBUF 1 /* mbuf */ #define M_DEVBUF 2 /* device driver memory */ -/* 3 - free */ +#define M_DEBUG 3 /* debug chunk */ #define M_PCB 4 /* protocol control block */ #define M_RTABLE 5 /* routing tables */ /* 6 - free */ @@ -173,7 +173,7 @@ "free", /* 0 M_FREE */ \ "mbuf", /* 1 M_MBUF */ \ "devbuf", /* 2 M_DEVBUF */ \ - NULL, \ + "debug", /* 3 M_DEBUG */ \ "pcb", /* 4 M_PCB */ \ "routetbl", /* 5 M_RTABLE */ \ NULL, /* 6 */ \ |