FreeBSD/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
/*
 * We perform an equivalency check on two subgraphs by traversing through them
 * in lockstep.  If a given node is equivalent in both the parent and the child,
 * we mark it in both subgraphs, using the t_emark field, with a monotonically
 * increasing number.  If, in the course of the traversal, we reach a node that
 * we have visited and numbered during this equivalency check, we have a cycle.
 * If the previously-visited nodes don't have the same emark, then the edges
 * that brought us to these nodes are not equivalent, and so the check ends.
 * If the emarks are the same, the edges are equivalent.  We then backtrack and
 * continue the traversal.  If we have exhausted all edges in the subgraph, and
 * have not found any inequivalent nodes, then the subgraphs are equivalent.
 */
We perform an equivalency check on two subgraphs by traversing through them
in lockstep.  If a given node is equivalent in both the parent and the child,
we mark it in both subgraphs, using the t_emark field, with a monotonically
increasing number.  If, in the course of the traversal, we reach a node that
we have visited and numbered during this equivalency check, we have a cycle.
If the previously-visited nodes don't have the same emark, then the edges
that brought us to these nodes are not equivalent, and so the check ends.
If the emarks are the same, the edges are equivalent.  We then backtrack and
continue the traversal.  If we have exhausted all edges in the subgraph, and
have not found any inequivalent nodes, then the subgraphs are equivalent.
We perform an equivalency check on two subgraphs by traversing through them in lockstep . If a given node is equivalent in both the parent and the child we mark it in both subgraphs using the t_emark field with a monotonically increasing number . If in the course of the traversal we reach a node that we have visited and numbered during this equivalency check we have a cycle . If the previously - visited nodes don ' t have the same emark then the edges that brought us to these nodes are not equivalent and so the check ends . If the emarks are the same the edges are equivalent . We then backtrack and continue the traversal . If we have exhausted all edges in the subgraph and have not found any inequivalent nodes then the subgraphs are equivalent .
static int
equiv_cb(void *bucket, void *arg)
{
	equiv_data_t *ed = arg;
	tdesc_t *mtdp = bucket;
	tdesc_t *ctdp = ed->ed_node;
	ed->ed_clear_mark = ed->ed_cur_mark + 1;
	ed->ed_cur_mark = ed->ed_clear_mark + 1;
	if (equiv_node(ctdp, mtdp, ed)) {
		debug(3, "equiv_node matched %d <%x> %d <%x>\n",
		    ctdp->t_id, ctdp->t_id, mtdp->t_id, mtdp->t_id);
		ed->ed_tgt = mtdp;
		return (-1);
	}
	return (0);
}
static int equiv_cb ( void * bucket , void * arg ) { equiv_data_t * ed = arg ; tdesc_t * mtdp = bucket ; tdesc_t * ctdp = ed -> ed_node ; ed -> ed_clear_mark = ed -> ed_cur_mark + 1 ; ed -> ed_cur_mark = ed -> ed_clear_mark + 1 ; if ( equiv_node ( ctdp , mtdp , ed ) ) { debug ( 3 , " \n " , ctdp -> t_id , ctdp -> t_id , mtdp -> t_id , mtdp -> t_id ) ; ed -> ed_tgt = mtdp ; return ( -1 ) ; } return ( 0 ) ; }
We perform an equivalency check on two subgraphs by traversing through them
 in lockstep.
We perform an equivalency check on two subgraphs by traversing through them in lockstep .
/* matched.  stop looking */