diff options
author | phk <phk@FreeBSD.org> | 1997-10-28 19:01:02 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1997-10-28 19:01:02 +0000 |
commit | 349f4dfe035d86ca42c2320bc91fc94acd12ce10 (patch) | |
tree | c0f84be2a358607b7304807f3e34268284e3e337 | |
parent | 1e49b12039a3e0f391576405bb97723f4ad6024b (diff) | |
download | FreeBSD-src-349f4dfe035d86ca42c2320bc91fc94acd12ce10.zip FreeBSD-src-349f4dfe035d86ca42c2320bc91fc94acd12ce10.tar.gz |
Remove the long description from the in-kernel datastructure.
Put a magic field in there instead, to help catch uninitialized
malloc types.
-rw-r--r-- | sys/kern/kern_malloc.c | 5 | ||||
-rw-r--r-- | sys/sys/malloc.h | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index df84db6..6677420 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94 - * $Id: kern_malloc.c,v 1.35 1997/10/11 13:13:09 phk Exp $ + * $Id: kern_malloc.c,v 1.36 1997/10/12 20:23:51 phk Exp $ */ #include <sys/param.h> @@ -405,6 +405,9 @@ malloc_init(type) { int npg; + if (type->ks_magic != M_MAGIC) + panic("malloc type lacks magic"); + /* * Limit maximum memory for each type to 60% of malloc area size or * 60% of physical memory, whichever is smaller. diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 92fd095..cf7ef0e 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)malloc.h 8.5 (Berkeley) 5/3/95 - * $Id: malloc.h,v 1.29 1997/10/11 18:31:36 phk Exp $ + * $Id: malloc.h,v 1.30 1997/10/12 20:25:59 phk Exp $ */ #ifndef _SYS_MALLOC_H_ @@ -46,9 +46,11 @@ #define M_NOWAIT 0x0001 #define M_KERNEL 0x0002 +#define M_MAGIC 877983977 /* time when first defined :-) */ + struct malloc_type { const char * const ks_shortdesc; /* Short description */ - const char * const ks_longdesc; /* Long description */ + u_long ks_magic; /* If if's not magic, don't touch it */ struct malloc_type *ks_next; /* Next pointer */ long ks_inuse; /* # of packets of this type currently in use */ long ks_calls; /* total packets of this type ever allocated */ @@ -61,7 +63,7 @@ struct malloc_type { }; #define MALLOC_DEFINE(type, shortdesc, longdesc) \ - struct malloc_type type[1] = { { shortdesc, longdesc } }; \ + struct malloc_type type[1] = { { shortdesc, M_MAGIC } }; \ struct __hack #define MALLOC_DECLARE(type) \ |