diff options
| author | Jeff Roberson <jeff@FreeBSD.org> | 2002-05-02 09:07:04 +0000 |
|---|---|---|
| committer | Jeff Roberson <jeff@FreeBSD.org> | 2002-05-02 09:07:04 +0000 |
| commit | 8f70816cf260ae0116e8616c79bdfc63e52928e1 (patch) | |
| tree | d04d4200ce8e73582726b459fe3a5978841495d0 /sys/kern/kern_malloc.c | |
| parent | b9ba89317958b9834349f1328eb08b47a17dcb51 (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_malloc.c')
| -rw-r--r-- | sys/kern/kern_malloc.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index d45518a8d2d8..5e48278e1aa0 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -229,7 +229,25 @@ free(addr, type) addr, mem); if (!(slab->us_flags & UMA_SLAB_MALLOC)) { +#ifdef INVARIANTS + struct malloc_type **mtp = addr; +#endif size = slab->us_zone->uz_size; +#ifdef INVARIANTS + /* + * Cache a pointer to the malloc_type that most recently freed + * this memory here. This way we know who is most likely to + * have stepped on it later. + * + * This code assumes that size is a multiple of 8 bytes for + * 64 bit machines + */ + mtp = (struct malloc_type **) + ((unsigned long)mtp & ~UMA_ALIGN_PTR); + mtp += (size - sizeof(struct malloc_type *)) / + sizeof(struct malloc_type *); + *mtp = type; +#endif uma_zfree_arg(slab->us_zone, addr, slab); } else { size = slab->us_size; @@ -398,7 +416,7 @@ kmeminit(dummy) kmemzones[indx].kz_zone = uma_zcreate(name, size, #ifdef INVARIANTS - trash_ctor, trash_dtor, trash_init, trash_fini, + mtrash_ctor, mtrash_dtor, mtrash_init, mtrash_fini, #else NULL, NULL, NULL, NULL, #endif |
