FreeBSD/sys/netpfil/ipfw/dn_heap.c
/*
 * do a scan with the option to delete the object. Extract next before
 * running the callback because the element may be destroyed there.
 */
do a scan with the option to delete the object. Extract next before
running the callback because the element may be destroyed there.
do a scan with the option to delete the object . Extract next before running the callback because the element may be destroyed there .
int
dn_ht_scan(struct dn_ht *ht, int (*fn)(void *, void *), void *arg)
{
	int i, ret, found = 0;
	void **curp, *cur, *next;
	if (ht == NULL || fn == NULL)
		return 0;
	for (i = 0; i <= ht->buckets; i++) {
		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 ( struct dn_ht * ht , int ( * fn ) ( void * , void * ) , void * arg ) { int i , ret , found = 0 ; void * * curp , * cur , * next ; if ( ht == NULL || fn == NULL ) return 0 ; for ( i = 0 ; i <= ht -> buckets ; i ++ ) { 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 ; }
do a scan with the option to delete the object.
do a scan with the option to delete the object .