FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Allocate new bitmask which can be used to enlarge/shrink
 * named instance index.
 */
Allocate new bitmask which can be used to enlarge/shrink
named instance index.
Allocate new bitmask which can be used to enlarge / shrink named instance index .
void
ipfw_objhash_bitmap_alloc(uint32_t items, void **idx, int *pblocks)
{
	size_t size;
	int max_blocks;
	u_long *idx_mask;
	KASSERT((items % BLOCK_ITEMS) == 0,
	   ("bitmask size needs to power of 2 and greater or equal to %zu",
	    BLOCK_ITEMS));
	max_blocks = items / BLOCK_ITEMS;
	size = items / 8;
	idx_mask = malloc(size * IPFW_MAX_SETS, M_IPFW, M_WAITOK);
	memset(idx_mask, 0xFF, size * IPFW_MAX_SETS);
	*idx_mask &= ~(u_long)1; 
	*idx = idx_mask;
	*pblocks = max_blocks;
}
void ipfw_objhash_bitmap_alloc ( uint32_t items , void * * idx , int * pblocks ) { size_t size ; int max_blocks ; u_long * idx_mask ; KASSERT ( ( items % BLOCK_ITEMS ) == 0 , ( " " , BLOCK_ITEMS ) ) ; max_blocks = items / BLOCK_ITEMS ; size = items / 8 ; idx_mask = malloc ( size * IPFW_MAX_SETS , M_IPFW , M_WAITOK ) ; memset ( idx_mask , 0xFF , size * IPFW_MAX_SETS ) ; * idx_mask &= ~ ( u_long ) 1 ; * idx = idx_mask ; * pblocks = max_blocks ; }
Allocate new bitmask which can be used to enlarge/shrink
 named instance index.
Allocate new bitmask which can be used to enlarge / shrink named instance index .
/* Mark all as free */ /* Skip index 0 */