FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Allocate new index in given instance and stores in in @pidx.
 * Returns 0 on success.
 */
Allocate new index in given instance and stores in in @pidx.
Returns 0 on success.
Allocate new index in given instance and stores in in @pidx . Returns 0 on success .
int
ipfw_objhash_alloc_idx(void *n, uint16_t *pidx)
{
	struct namedobj_instance *ni;
	u_long *mask;
	int i, off, v;
	ni = (struct namedobj_instance *)n;
	off = ni->free_off[0];
	mask = &ni->idx_mask[off];
	for (i = off; i < ni->max_blocks; i++, mask++) {
		if ((v = ffsl(*mask)) == 0)
			continue;
		*mask &= ~ ((u_long)1 << (v - 1));
		ni->free_off[0] = i;
		v = BLOCK_ITEMS * i + v - 1;
		*pidx = v;
		return (0);
	}
	return (1);
}
int ipfw_objhash_alloc_idx ( void * n , uint16_t * pidx ) { struct namedobj_instance * ni ; u_long * mask ; int i , off , v ; ni = ( struct namedobj_instance * ) n ; off = ni -> free_off [ 0 ] ; mask = & ni -> idx_mask [ off ] ; for ( i = off ; i < ni -> max_blocks ; i ++ , mask ++ ) { if ( ( v = ffsl ( * mask ) ) == 0 ) continue ; * mask &= ~ ( ( u_long ) 1 << ( v - 1 ) ) ; ni -> free_off [ 0 ] = i ; v = BLOCK_ITEMS * i + v - 1 ; * pidx = v ; return ( 0 ) ; } return ( 1 ) ; }
Allocate new index in given instance and stores in in @pidx.
Allocate new index in given instance and stores in in @pidx .
/* Mark as busy */