FreeBSD/contrib/ntp/libntp/authkeys.c
/*
 * freesymkey - common code to remove a symkey and recycle its entry.
 */
common code to remove a symkey and recycle its entry.
common code to remove a symkey and recycle its entry .
static void
freesymkey(
	symkey *	sk
	)
{
	symkey **	bucket;
	symkey *	unlinked;
	if (NULL == sk)
		return;
	authcache_flush_id(sk->keyid);
	keyacc_all_free(sk->keyacclist);
	bucket = &key_hash[KEYHASH(sk->keyid)];
	if (sk->secret != NULL) {
		memset(sk->secret, '\0', sk->secretsize);
		free(sk->secret);
	}
	UNLINK_SLIST(unlinked, *bucket, sk, hlink, symkey);
	DEBUG_ENSURE(sk == unlinked);
	UNLINK_DLIST(sk, llink);
	memset((char *)sk + offsetof(symkey, symkey_payload), '\0',
	       sizeof(*sk) - offsetof(symkey, symkey_payload));
	LINK_SLIST(authfreekeys, sk, llink.f);
	authnumkeys--;
	authnumfreekeys++;
}
static void freesymkey ( symkey * sk ) { symkey * * bucket ; symkey * unlinked ; if ( NULL == sk ) return ; authcache_flush_id ( sk -> keyid ) ; keyacc_all_free ( sk -> keyacclist ) ; bucket = & key_hash [ KEYHASH ( sk -> keyid ) ] ; if ( sk -> secret != NULL ) { memset ( sk -> secret , ' \0 ' , sk -> secretsize ) ; free ( sk -> secret ) ; } UNLINK_SLIST ( unlinked , * bucket , sk , hlink , symkey ) ; DEBUG_ENSURE ( sk == unlinked ) ; UNLINK_DLIST ( sk , llink ) ; memset ( ( char * ) sk + offsetof ( symkey , symkey_payload ) , ' \0 ' , sizeof ( * sk ) - offsetof ( symkey , symkey_payload ) ) ; LINK_SLIST ( authfreekeys , sk , llink . f ) ; authnumkeys -- ; authnumfreekeys ++ ; }
freesymkey - common code to remove a symkey and recycle its entry.
freesymkey - common code to remove a symkey and recycle its entry .