Remove the long description from the in-kernel datastructure.
Put a magic field in there instead, to help catch uninitialized malloc types.
This commit is contained in:
parent
bc189bf8f7
commit
d1bbc7ec65
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30817
@ -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.
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user