FreeBSD/usr.bin/gprof/dfn.c
/*
     *	given this parent, depth first number its children.
     */
given this parent, depth first number its children.
given this parent depth first number its children .
void
dfn(nltype *parentp)
{
    arctype	*arcp;
#   ifdef DEBUG
	if ( debug & DFNDEBUG ) {
	    printf( "[dfn] dfn(" );
	    printname( parentp );
	    printf( ")\n" );
	}
#   endif 
    if ( dfn_numbered( parentp ) ) {
	return;
    }
    if ( dfn_busy( parentp ) ) {
	dfn_findcycle( parentp );
	return;
    }
    dfn_pre_visit( parentp );
    for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) {
	    if ( arcp -> arc_flags & DEADARC )
		continue;
	    dfn( arcp -> arc_childp );
    }
    dfn_post_visit( parentp );
}
void dfn ( nltype * parentp ) { arctype * arcp ; #   ifdef DEBUG if ( debug & DFNDEBUG ) { printf ( " " ) ; printname ( parentp ) ; printf ( " \n " ) ; } #   endif if ( dfn_numbered ( parentp ) ) { return ; } if ( dfn_busy ( parentp ) ) { dfn_findcycle ( parentp ) ; return ; } dfn_pre_visit ( parentp ) ; for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) { if ( arcp -> arc_flags & DEADARC ) continue ; dfn ( arcp -> arc_childp ) ; } dfn_post_visit ( parentp ) ; }
given this parent, depth first number its children.
given this parent depth first number its children .
/* DEBUG */ /*
	 *	if we're already numbered, no need to look any further.
	 */ /*
	 *	if we're already busy, must be a cycle
	 */ /*
	 *	visit yourself before your children
	 */ /*
	 *	visit children
	 */ /*
	 *	visit yourself after your children
	 */