usr.sbin/config.new/pack.c
/*
 * Pack instances together wherever possible.  When everything is
 * packed, go back and set up the parents for each.  We must do this
 * on a second pass because during the first one, we do not know which,
 * if any, of the parents will collapse during packing.
 */
Pack instances together wherever possible.  When everything is
packed, go back and set up the parents for each.  We must do this
on a second pass because during the first one, we do not know which,
if any, of the parents will collapse during packing.
Pack instances together wherever possible . When everything is packed go back and set up the parents for each . We must do this on a second pass because during the first one we do not know which if any of the parents will collapse during packing .
void
packdevi()
{
	register struct devi *i, *l, *p;
	register struct devbase *d;
	register int j, m, n;
	packed = emalloc((ndevi + 1) * sizeof *packed);
	n = 0;
	for (d = allbases; d != NULL; d = d->d_next) {
		for (i = d->d_ihead; i != NULL; i = i->i_bsame) {
			m = n;
			for (l = i; l != NULL; l = l->i_alias) {
				l->i_pvlen = 0;
				l->i_pvoff = -1;
				l->i_locoff = -1;
				l->i_ivoff = -1;
				for (j = m; j < n; j++) {
					p = packed[j];
					if (sameas(l, p)) {
						l->i_collapsed = 1;
						l->i_cfindex = p->i_cfindex;
						goto nextalias;
					}
				}
				l->i_collapsed = 0;
				l->i_cfindex = n;
				l->i_parents = emalloc(sizeof(*l->i_parents));
				l->i_parents[0] = NULL;
				packed[n++] = l;
			nextalias:;
			}
		}
	}
	npacked = n;
	packed[n] = NULL;
	for (i = alldevi; i != NULL; i = i->i_next)
		addparents(i, packed[i->i_cfindex]);
}
void packdevi ( ) { register struct devi * i , * l , * p ; register struct devbase * d ; register int j , m , n ; packed = emalloc ( ( ndevi + 1 ) * sizeof * packed ) ; n = 0 ; for ( d = allbases ; d != NULL ; d = d -> d_next ) { for ( i = d -> d_ihead ; i != NULL ; i = i -> i_bsame ) { m = n ; for ( l = i ; l != NULL ; l = l -> i_alias ) { l -> i_pvlen = 0 ; l -> i_pvoff = -1 ; l -> i_locoff = -1 ; l -> i_ivoff = -1 ; for ( j = m ; j < n ; j ++ ) { p = packed [ j ] ; if ( sameas ( l , p ) ) { l -> i_collapsed = 1 ; l -> i_cfindex = p -> i_cfindex ; goto nextalias ; } } l -> i_collapsed = 0 ; l -> i_cfindex = n ; l -> i_parents = emalloc ( sizeof ( * l -> i_parents ) ) ; l -> i_parents [ 0 ] = NULL ; packed [ n ++ ] = l ; nextalias : ; } } } npacked = n ; packed [ n ] = NULL ; for ( i = alldevi ; i != NULL ; i = i -> i_next ) addparents ( i , packed [ i -> i_cfindex ] ) ; }
Pack instances together wherever possible.
Pack instances together wherever possible .
/*
		 * For each instance of each device, add or collapse
		 * all its aliases.
		 */ /* try to find an equivalent for l */ /* could not find a suitable alias */