summaryrefslogtreecommitdiff
path: root/ACE
diff options
context:
space:
mode:
authorsma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-23 12:45:54 +0000
committersma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-05-23 12:45:54 +0000
commit2a36acbcfcd7b7e202ed41f2f3f34fd0412d28d8 (patch)
tree84c660f4b387340bd31e813ada2f568b41897a46 /ACE
parent186385c0fcb1e7ca5830e1a907d28b4956c71fd2 (diff)
downloadATCD-2a36acbcfcd7b7e202ed41f2f3f34fd0412d28d8.tar.gz
ChangeLogTag: Fri May 23 12:45:00 UTC 2008 Simon Massey <sma at prismtech dot com>
Diffstat (limited to 'ACE')
-rw-r--r--ACE/ChangeLog7
-rw-r--r--ACE/ace/RB_Tree.cpp52
2 files changed, 56 insertions, 3 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 3ecccd6b630..6a93923b332 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,10 @@
+Fri May 23 12:45:00 UTC 2008 Simon Massey <sma at prismtech dot com>
+
+ * ace/RB_Tree.cpp:
+
+ Enhancement to stop external pointers to retained items being
+ invalidated upon key deletion.
+
Fri May 23 12:14:54 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
* ace/Monitor_Control/Auto_Update_Starter.h:
diff --git a/ACE/ace/RB_Tree.cpp b/ACE/ace/RB_Tree.cpp
index 91cefa0f037..8e3992aad06 100644
--- a/ACE/ace/RB_Tree.cpp
+++ b/ACE/ace/RB_Tree.cpp
@@ -1030,9 +1030,55 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<
if (y != z)
{
- // Copy the elements of y into z.
- z->key () = y->key ();
- z->item () = y->item ();
+ // Replace node z with node y, since y's pointer may well be
+ // held externally, and be linked with y's key and item.
+ // We will end up deleting the old unlinked, node z.
+
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *zParent = z->parent ();
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *zLeftChild = z->left ();
+ ACE_RB_Tree_Node<EXT_ID, INT_ID> *zRightChild = z->right ();
+
+ if (zParent)
+ {
+ if (z == zParent->left ())
+ {
+ zParent->left (y);
+ }
+ else
+ {
+ zParent->right (y);
+ }
+ }
+ else
+ {
+ this->root_ = y;
+ }
+ y->parent (zParent);
+
+ if (zLeftChild)
+ {
+ zLeftChild->parent (y);
+ }
+ y->left (zLeftChild);
+
+ if (zRightChild)
+ {
+ zRightChild->parent (y);
+ }
+ y->right (zRightChild);
+
+ if (parent == z)
+ {
+ parent = y;
+ }
+
+ ACE_RB_Tree_Node_Base::RB_Tree_Node_Color yColor = y->color ();
+ y->color (z->color ());
+ z->color (yColor);
+
+ //Reassign the y pointer to z because the node that y points to will be
+ //deleted
+ y = z;
}
// CLR pp. 263 says that nil nodes are implicitly colored BLACK