Changeset 7 in kStuff for trunk/include/k/kAvlTmpl/kAvlRemove2.h
- Timestamp:
- Feb 4, 2008 2:08:02 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/include/k/kAvlTmpl/kAvlRemove2.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/k/kAvlTmpl/kAvlRemove2.h
r2 r7 37 37 * 38 38 * @returns Pointer to the removed node (NULL if not in the tree) 39 * @param p pTree Pointer to Pointer to the tree root node.39 * @param pRoot Pointer to the AVL-tree root structure. 40 40 * @param Key The Key of which is to be found a best fitting match for.. 41 41 * … … 43 43 * easier to manage. 44 44 */ 45 KAVL_DECL(KAVLNODE *) KAVL_FN(Remove2)(KAVLTR EEPTR *ppTree, KAVLNODE *pNode)45 KAVL_DECL(KAVLNODE *) KAVL_FN(Remove2)(KAVLTROOT *pRoot, KAVLNODE *pNode) 46 46 { 47 47 #ifdef KAVL_EQUAL_ALLOWED … … 50 50 */ 51 51 KAVLNODE *pParent; 52 KAVLNODE *pCurNode = KAVL_FN(GetWithParent)(p pTree, pNode->mKey, &pParent);52 KAVLNODE *pCurNode = KAVL_FN(GetWithParent)(pRoot, pNode->mKey, &pParent); 53 53 if (!pCurNode) 54 54 return NULL; 55 KAVL_WRITE_LOCK(pRoot); /** @todo the locking here isn't 100% sane. The only way to archive that is by no calling worker functions. */ 55 56 if (pCurNode != pNode) 56 57 { … … 65 66 KAVL_SET_POINTER_NULL(&pCurNode->mpList, KAVL_GET_POINTER_NULL(&pNode->mpList)); 66 67 pNode->mpList = KAVL_NULL; 68 KAVL_LOOKTHRU_INVALIDATE_NODE(pRoot, pNode, pNode->mKey); 69 KAVL_WRITE_UNLOCK(pRoot); 67 70 return pNode; 68 71 } 69 72 pCurNode = pNext; 70 73 } 74 KAVL_WRITE_UNLOCK(pRoot); 71 75 return NULL; 72 76 } … … 80 84 */ 81 85 if (pNode->mpList == KAVL_NODE) 82 KAVL_FN(Remove)(ppTree, pNode->mKey); 86 { 87 KAVL_WRITE_UNLOCK(pRoot); 88 KAVL_FN(Remove)(pRoot, pNode->mKey); 89 } 83 90 else 84 91 { … … 105 112 } 106 113 else 107 KAVL_SET_POINTER(ppTree, pNewUs); 114 KAVL_SET_POINTER(&pRoot->mpRoot, pNewUs); 115 116 KAVL_LOOKTHRU_INVALIDATE_NODE(pRoot, pNode, pNode->mKey); 117 KAVL_WRITE_UNLOCK(pRoot); 108 118 } 119 109 120 return pNode; 110 121 … … 116 127 * of wrong nodes but just uses this API for his convenience. 117 128 */ 118 KAVLNODE *pRemovedNode = KAVL_FN(Remove)(p pTree, pNode->mKey);129 KAVLNODE *pRemovedNode = KAVL_FN(Remove)(pRoot, pNode->mKey); 119 130 if (pRemovedNode == pNode) 120 131 return pRemovedNode; 121 132 122 KAVL_FN(Insert)(p pTree, pRemovedNode);133 KAVL_FN(Insert)(pRoot, pRemovedNode); 123 134 return NULL; 124 135 #endif
Note:
See TracChangeset
for help on using the changeset viewer.

