/*
***************************************************************************
-* Copyright (C) 2002-2003 International Business Machines Corporation *
+* Copyright (C) 2002-2008 International Business Machines Corporation *
* and others. All rights reserved. *
***************************************************************************
*/
U_NAMESPACE_BEGIN
-int RBBINode::gLastSerial = 0;
-
+#ifdef RBBI_DEBUG
+static int gLastSerial = 0;
+#endif
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
RBBINode::RBBINode(NodeType t) : UMemory() {
+#ifdef RBBI_DEBUG
fSerialNum = ++gLastSerial;
+#endif
fType = t;
fParent = NULL;
fLeftChild = NULL;
RBBINode::RBBINode(const RBBINode &other) : UMemory(other) {
+#ifdef RBBI_DEBUG
fSerialNum = ++gLastSerial;
+#endif
fType = other.fType;
fParent = NULL;
fLeftChild = NULL;
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;