X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..e4f10fab0c078f399c9deef476d9c9b73b47dff8:/icuSources/common/rbbinode.cpp?ds=sidebyside diff --git a/icuSources/common/rbbinode.cpp b/icuSources/common/rbbinode.cpp index b873f218..49e0ad3d 100644 --- a/icuSources/common/rbbinode.cpp +++ b/icuSources/common/rbbinode.cpp @@ -1,6 +1,6 @@ /* *************************************************************************** -* Copyright (C) 2002-2003 International Business Machines Corporation * +* Copyright (C) 2002-2008 International Business Machines Corporation * * and others. All rights reserved. * *************************************************************************** */ @@ -33,8 +33,9 @@ U_NAMESPACE_BEGIN -int RBBINode::gLastSerial = 0; - +#ifdef RBBI_DEBUG +static int gLastSerial = 0; +#endif //------------------------------------------------------------------------- @@ -43,7 +44,9 @@ int RBBINode::gLastSerial = 0; // //------------------------------------------------------------------------- RBBINode::RBBINode(NodeType t) : UMemory() { +#ifdef RBBI_DEBUG fSerialNum = ++gLastSerial; +#endif fType = t; fParent = NULL; fLeftChild = NULL; @@ -69,7 +72,9 @@ RBBINode::RBBINode(NodeType t) : UMemory() { RBBINode::RBBINode(const RBBINode &other) : UMemory(other) { +#ifdef RBBI_DEBUG fSerialNum = ++gLastSerial; +#endif fType = other.fType; fParent = NULL; fLeftChild = NULL; @@ -144,13 +149,16 @@ RBBINode *RBBINode::cloneTree() { n = this; } else { n = new RBBINode(*this); - if (fLeftChild != NULL) { - n->fLeftChild = fLeftChild->cloneTree(); - n->fLeftChild->fParent = n; - } - if (fRightChild != NULL) { - n->fRightChild = fRightChild->cloneTree(); - n->fRightChild->fParent = n; + // Check for null pointer. + if (n != NULL) { + if (fLeftChild != NULL) { + n->fLeftChild = fLeftChild->cloneTree(); + n->fLeftChild->fParent = n; + } + if (fRightChild != NULL) { + n->fRightChild = fRightChild->cloneTree(); + n->fRightChild->fParent = n; + } } } return n;