bug in pfuTraverse()

New Message Reply Date view Thread view Subject view Author view

Alon Rosenfeld 18 Hatzedef street Jaffa (alon++at++bvr.co.il)
Thu, 30 Jun 1994 18:48:41 +0000


Hi,

I believe that there is a bug in the pfuTraverse() routine.

The bug is such that every time the routine recursively enters itself, it
writes the node (given as a parameter) into trav->node. The fact that trav is a
pointer to a single copy of the trav structure (initially passed by the user)
causes the last assignment of trav->node to hold and in turn the postFunc will
get a trav pointer with a wrong node pointer (that of the last visited node in
the recursion).

I fixed it as follows:

pfuTraverse(pfNode *node, pfuTraverser *trav)
{
pfMatrix mat;
 .
 .
pfNode *keep_node;

        keep_node = trav->node;
        trav->node = (pfNode *)node;
        .
        .
        .
        .

        .
        if (trav->postFunc)
        (*trav->postFunc)(trav);

        trav -> node = keep_node;
        return PFTRAV_CONT;
}

Thats it I guess

Alon


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:22 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.