From: kim Date: Tue, 27 Jan 2009 00:53:35 +0000 (+0000) Subject: Add check for Root Node to the parent function X-Git-Url: http://git.nguyen.vg/gitweb/?a=commitdiff_plain;ds=sidebyside;h=22ee86b6a6088bf49747da202d619439fd8880e2;p=SXSI%2FXMLTree.git Add check for Root Node to the parent function git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@66 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- diff --git a/XMLTree.cpp b/XMLTree.cpp index 3c51b2f..21658e9 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -311,8 +311,10 @@ treeNode XMLTree::Parent(treeNode x) fprintf(stderr, "Error: data structure has not been constructed properly\n"); exit(1); } - - return parent(Par, x); + if (x == Root()) + return NULLT; + else + return parent(Par, x); } // Child(x,i): returns the i-th child of node x, assuming it exists.