FreeBSD/sys/kern/subr_blist.c
/*
 * BLST_RADIX_INIT() - initialize radix tree
 *
 *	Initialize our meta structures and bitmaps and calculate the exact
 *	amount of space required to manage 'count' blocks - this space may
 *	be considerably less than the calculated radix due to the large
 *	RADIX values we use.
 */
initialize radix tree
Initialize our meta structures and bitmaps and calculate the exact
amount of space required to manage 'count' blocks - this space may
be considerably less than the calculated radix due to the large
RADIX values we use.
initialize radix tree Initialize our meta structures and bitmaps and calculate the exact amount of space required to manage ' count ' blocks - this space may be considerably less than the calculated radix due to the large RADIX values we use .
static daddr_t	
blst_radix_init(blmeta_t *scan, daddr_t radix, int skip, daddr_t count)
{
	int i;
	int next_skip;
	daddr_t memindex = 0;
	if (radix == BLIST_BMAP_RADIX) {
		if (scan) {
			scan->bm_bighint = 0;
			scan->u.bmu_bitmap = 0;
		}
		return(memindex);
	}
	if (scan) {
		scan->bm_bighint = 0;
		scan->u.bmu_avail = 0;
	}
	radix /= BLIST_META_RADIX;
	next_skip = ((u_int)skip / BLIST_META_RADIX);
	for (i = 1; i <= skip; i += next_skip) {
		if (count >= radix) {
			memindex = i + blst_radix_init(
			    ((scan) ? &scan[i] : NULL),
			    radix,
			    next_skip - 1,
			    radix
			);
			count -= radix;
		} else if (count > 0) {
			memindex = i + blst_radix_init(
			    ((scan) ? &scan[i] : NULL),
			    radix,
			    next_skip - 1,
			    count
			);
			count = 0;
		} else {
			if (scan)
				scan[i].bm_bighint = (daddr_t)-1;
			break;
		}
	}
	if (memindex < i)
		memindex = i;
	return(memindex);
}
static daddr_t blst_radix_init ( blmeta_t * scan , daddr_t radix , int skip , daddr_t count ) { int i ; int next_skip ; daddr_t memindex = 0 ; if ( radix == BLIST_BMAP_RADIX ) { if ( scan ) { scan -> bm_bighint = 0 ; scan -> u . bmu_bitmap = 0 ; } return ( memindex ) ; } if ( scan ) { scan -> bm_bighint = 0 ; scan -> u . bmu_avail = 0 ; } radix /= BLIST_META_RADIX ; next_skip = ( ( u_int ) skip / BLIST_META_RADIX ) ; for ( i = 1 ; i <= skip ; i += next_skip ) { if ( count >= radix ) { memindex = i + blst_radix_init ( ( ( scan ) ? & scan [ i ] : NULL ) , radix , next_skip - 1 , radix ) ; count -= radix ; } else if ( count > 0 ) { memindex = i + blst_radix_init ( ( ( scan ) ? & scan [ i ] : NULL ) , radix , next_skip - 1 , count ) ; count = 0 ; } else { if ( scan ) scan [ i ] . bm_bighint = ( daddr_t ) - 1 ; break ; } } if ( memindex < i ) memindex = i ; return ( memindex ) ; }
BLST_RADIX_INIT() - initialize radix tree
      Initialize our meta structures and bitmaps and calculate the exact
      amount of space required to manage 'count' blocks - this space may
      be considerably less than the calculated radix due to the large
      RADIX values we use.
BLST_RADIX_INIT () - initialize radix tree Initialize our meta structures and bitmaps and calculate the exact amount of space required to manage ' count ' blocks - this space may be considerably less than the calculated radix due to the large RADIX values we use .
/*
	 * Leaf node
	 */ /*
	 * Meta node.  If allocating the entire object we can special
	 * case it.  However, we need to figure out how much memory
	 * is required to manage 'count' blocks, so we continue on anyway.
	 */ /*
			 * Allocate the entire object
			 */ /*
			 * Allocate a partial object
			 */ /*
			 * Add terminator and break out
			 */