Index: sys/kern/kern_malloc.c =================================================================== --- sys/kern/kern_malloc.c +++ sys/kern/kern_malloc.c @@ -1030,6 +1030,23 @@ return (mem); } +/* + * malloc_size2zone: returns the usable size if an allocation is performed. + */ +size_t +malloc_size2zone(size_t size) +{ + int indx; + + if (size > kmem_zmax) { + return (-1); + } + if (size & KMEM_ZMASK) + size = (size & ~KMEM_ZMASK) + KMEM_ZBASE; + indx = kmemsize[size >> KMEM_ZSHIFT]; + return (kmemzones[indx].kz_size); +} + /* * malloc_usable_size: returns the usable size of the allocation. */ Index: sys/sys/malloc.h =================================================================== --- sys/sys/malloc.h +++ sys/sys/malloc.h @@ -251,6 +251,7 @@ void malloc_type_list(malloc_type_list_func_t *, void *); void malloc_uninit(void *); size_t malloc_usable_size(const void *); +size_t malloc_size2zone(size_t); void *realloc(void *addr, size_t size, struct malloc_type *type, int flags) __result_use_check __alloc_size(2); void *reallocf(void *addr, size_t size, struct malloc_type *type, int flags)