MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zfree

Function zfree

freebsd/kern/kern_malloc.c:906–939  ·  view source on GitHub ↗

* zfree: * * Zero then free a block of memory allocated by malloc. * * This routine may not block. */

Source from the content-addressed store, hash-verified

904 * This routine may not block.
905 */
906void
907zfree(void *addr, struct malloc_type *mtp)
908{
909 uma_zone_t zone;
910 uma_slab_t slab;
911 u_long size;
912
913#ifdef MALLOC_DEBUG
914 if (free_dbg(&addr, mtp) != 0)
915 return;
916#endif
917 /* free(NULL, ...) does nothing */
918 if (addr == NULL)
919 return;
920
921 vtozoneslab((vm_offset_t)addr & (~UMA_SLAB_MASK), &zone, &slab);
922 if (slab == NULL)
923 panic("free: address %p(%p) has not been allocated.\n",
924 addr, (void *)((u_long)addr & (~UMA_SLAB_MASK)));
925
926 if (__predict_true(!malloc_large_slab(slab))) {
927 size = zone->uz_size;
928#ifdef INVARIANTS
929 free_save_type(addr, mtp, size);
930#endif
931 explicit_bzero(addr, size);
932 uma_zfree_arg(zone, addr, slab);
933 } else {
934 size = malloc_large_size(slab);
935 explicit_bzero(addr, size);
936 free_large(addr, size);
937 }
938 malloc_type_freed(mtp, size);
939}
940
941/*
942 * realloc: change the size of a memory block

Callers 15

kern_unsetenvFunction · 0.70
ktls_cleanupFunction · 0.70
kerneldumpcrypto_createFunction · 0.70
kerneldumpcomp_destroyFunction · 0.70
free_single_dumperFunction · 0.70
aesni_cipher_cryptFunction · 0.50
padlock_cipher_processFunction · 0.50
padlock_sha_freeFunction · 0.50
padlock_hash_freeFunction · 0.50
netdump_ioctlFunction · 0.50
swcr_freesessionFunction · 0.50

Calls 10

free_dbgFunction · 0.85
malloc_large_slabFunction · 0.85
free_save_typeFunction · 0.85
explicit_bzeroFunction · 0.85
uma_zfree_argFunction · 0.85
malloc_large_sizeFunction · 0.85
free_largeFunction · 0.85
malloc_type_freedFunction · 0.85
panicFunction · 0.70
vtozoneslabFunction · 0.50

Tested by

no test coverage detected