FreeBSD/sys/kern/kern_prot.c
/*
 * Free a cred structure.  Throws away space when ref count gets to 0.
 */
Free a cred structure.  Throws away space when ref count gets to 0.
Free a cred structure . Throws away space when ref count gets to 0 .
void
crfree(struct ucred *cr)
{
	KASSERT(cr->cr_ref > 0, ("bad ucred refcount: %d", cr->cr_ref));
	KASSERT(cr->cr_ref != 0xdeadc0de, ("dangling reference to ucred"));
	if (refcount_release(&cr->cr_ref)) {
		if (cr->cr_uidinfo != NULL)
			uifree(cr->cr_uidinfo);
		if (cr->cr_ruidinfo != NULL)
			uifree(cr->cr_ruidinfo);
		if (cr->cr_prison != NULL)
			prison_free(cr->cr_prison);
		if (cr->cr_loginclass != NULL)
			loginclass_free(cr->cr_loginclass);
#ifdef AUDIT
		audit_cred_destroy(cr);
#endif
#ifdef MAC
		mac_cred_destroy(cr);
#endif
		if (cr->cr_groups != cr->cr_smallgroups)
			free(cr->cr_groups, M_CRED);
		free(cr, M_CRED);
	}
}
void crfree ( struct ucred * cr ) { KASSERT ( cr -> cr_ref > 0 , ( " " , cr -> cr_ref ) ) ; KASSERT ( cr -> cr_ref != 0xdeadc0de , ( " " ) ) ; if ( refcount_release ( & cr -> cr_ref ) ) { if ( cr -> cr_uidinfo != NULL ) uifree ( cr -> cr_uidinfo ) ; if ( cr -> cr_ruidinfo != NULL ) uifree ( cr -> cr_ruidinfo ) ; if ( cr -> cr_prison != NULL ) prison_free ( cr -> cr_prison ) ; if ( cr -> cr_loginclass != NULL ) loginclass_free ( cr -> cr_loginclass ) ; #ifdef AUDIT audit_cred_destroy ( cr ) ; #endif #ifdef MAC mac_cred_destroy ( cr ) ; #endif if ( cr -> cr_groups != cr -> cr_smallgroups ) free ( cr -> cr_groups , M_CRED ) ; free ( cr , M_CRED ) ; } }
Free a cred structure.
Free a cred structure .
/*
		 * Some callers of crget(), such as nfs_statfs(),
		 * allocate a temporary credential, but don't
		 * allocate a uidinfo structure.
		 */ /*
		 * Free a prison, if any.
		 */