FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Adds one or more opcode object rewrite handlers to the global array.
 * Function may sleep.
 */
Adds one or more opcode object rewrite handlers to the global array.
Function may sleep.
Adds one or more opcode object rewrite handlers to the global array . Function may sleep .
void
ipfw_add_obj_rewriter(struct opcode_obj_rewrite *rw, size_t count)
{
	size_t sz;
	struct opcode_obj_rewrite *tmp;
	CTL3_LOCK();
	for (;;) {
		sz = ctl3_rsize + count;
		CTL3_UNLOCK();
		tmp = malloc(sizeof(*rw) * sz, M_IPFW, M_WAITOK | M_ZERO);
		CTL3_LOCK();
		if (ctl3_rsize + count <= sz)
			break;
		free(tmp, M_IPFW);
	}
	sz = ctl3_rsize + count;
	memcpy(tmp, ctl3_rewriters, ctl3_rsize * sizeof(*rw));
	memcpy(&tmp[ctl3_rsize], rw, count * sizeof(*rw));
	qsort(tmp, sz, sizeof(*rw), compare_opcodes);
	if (ctl3_rewriters != NULL)
		free(ctl3_rewriters, M_IPFW);
	ctl3_rewriters = tmp;
	ctl3_rsize = sz;
	CTL3_UNLOCK();
}
void ipfw_add_obj_rewriter ( struct opcode_obj_rewrite * rw , size_t count ) { size_t sz ; struct opcode_obj_rewrite * tmp ; CTL3_LOCK ( ) ; for ( ; ; ) { sz = ctl3_rsize + count ; CTL3_UNLOCK ( ) ; tmp = malloc ( sizeof ( * rw ) * sz , M_IPFW , M_WAITOK | M_ZERO ) ; CTL3_LOCK ( ) ; if ( ctl3_rsize + count <= sz ) break ; free ( tmp , M_IPFW ) ; } sz = ctl3_rsize + count ; memcpy ( tmp , ctl3_rewriters , ctl3_rsize * sizeof ( * rw ) ) ; memcpy ( & tmp [ ctl3_rsize ] , rw , count * sizeof ( * rw ) ) ; qsort ( tmp , sz , sizeof ( * rw ) , compare_opcodes ) ; if ( ctl3_rewriters != NULL ) free ( ctl3_rewriters , M_IPFW ) ; ctl3_rewriters = tmp ; ctl3_rsize = sz ; CTL3_UNLOCK ( ) ; }
Adds one or more opcode object rewrite handlers to the global array.
Adds one or more opcode object rewrite handlers to the global array .
/* Retry */ /* Merge old & new arrays */ /* Switch new and free old */