FreeBSD/sys/netpfil/ipfw/dn_heap.c
/*
 * Similar to dn_ht_scan(), except that the scan is performed only
 * in the bucket 'bucket'. The function returns a correct bucket number if
 * the original is invalid.
 * If the callback returns DNHT_SCAN_END, the function move the ht->ht[i]
 * pointer to the last entry processed. Moreover, the bucket number passed
 * by caller is decremented, because usually the caller increment it.
 */
Similar to dn_ht_scan(), except that the scan is performed only
in the bucket 'bucket'. The function returns a correct bucket number if
the original is invalid.
If the callback returns DNHT_SCAN_END, the function move the ht->ht[i]
pointer to the last entry processed. Moreover, the bucket number passed
by caller is decremented, because usually the caller increment it.
Similar to dn_ht_scan () except that the scan is performed only in the bucket ' bucket ' . The function returns a correct bucket number if the original is invalid . If the callback returns DNHT_SCAN_END the function move the ht - > ht [ i ] pointer to the last entry processed . Moreover the bucket number passed by caller is decremented because usually the caller increment it .
int
dn_ht_scan_bucket(struct dn_ht *ht, int *bucket, int (*fn)(void *, void *),
		 void *arg)
{
	int i, ret, found = 0;
	void **curp, *cur, *next;
	if (ht == NULL || fn == NULL)
		return 0;
	if (*bucket > ht->buckets)
		*bucket = 0;
	i = *bucket;
	curp = &ht->ht[i];
	while ( (cur = *curp) != NULL) {
		next = *(void **)((char *)cur + ht->ofs);
		ret = fn(cur, arg);
		if (ret & DNHT_SCAN_DEL) {
			found++;
			ht->entries--;
			*curp = next;
		} else {
			curp = (void **)((char *)cur + ht->ofs);
		}
		if (ret & DNHT_SCAN_END)
			return found;
	}
	return found;
}
int dn_ht_scan_bucket ( struct dn_ht * ht , int * bucket , int ( * fn ) ( void * , void * ) , void * arg ) { int i , ret , found = 0 ; void * * curp , * cur , * next ; if ( ht == NULL || fn == NULL ) return 0 ; if ( * bucket > ht -> buckets ) * bucket = 0 ; i = * bucket ; curp = & ht -> ht [ i ] ; while ( ( cur = * curp ) != NULL ) { next = * ( void * * ) ( ( char * ) cur + ht -> ofs ) ; ret = fn ( cur , arg ) ; if ( ret & DNHT_SCAN_DEL ) { found ++ ; ht -> entries -- ; * curp = next ; } else { curp = ( void * * ) ( ( char * ) cur + ht -> ofs ) ; } if ( ret & DNHT_SCAN_END ) return found ; } return found ; }
Similar to dn_ht_scan(), except that the scan is performed only
 in the bucket 'bucket'.
Similar to dn_ht_scan () except that the scan is performed only in the bucket ' bucket ' .