Changeset 7 in kStuff for trunk/include/k/kAvlTmpl/kAvlDestroy.h
- Timestamp:
- Feb 4, 2008 2:08:02 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/include/k/kAvlTmpl/kAvlDestroy.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/k/kAvlTmpl/kAvlDestroy.h
r2 r7 41 41 * made on it. Note that the node we fail on will be considered dead and 42 42 * no action is taken to link it back into the tree. 43 * @param p pTree Pointer to the AVL-tree root node pointer.43 * @param pRoot Pointer to the AVL-tree root structure. 44 44 * @param pfnCallBack Pointer to callback function. 45 45 * @param pvUser User parameter passed on to the callback function. 46 46 */ 47 KAVL_DECL(int) KAVL_FN(Destroy)(KAVL TREEPTR *ppTree, KAVL_TYPE(PFN,CALLBACK) pfnCallBack, void *pvUser)47 KAVL_DECL(int) KAVL_FN(Destroy)(KAVLROOT *pRoot, KAVL_TYPE(PFN,CALLBACK) pfnCallBack, void *pvUser) 48 48 { 49 #ifdef KAVL_LOOKTHRU 50 unsigned i; 51 #endif 49 52 unsigned cEntries; 50 53 KAVLNODE *apEntries[KAVL_MAX_STACK]; 51 54 int rc; 52 55 53 if (*ppTree == KAVL_NULL) 56 KAVL_WRITE_LOCK(pRoot); 57 if (pRoot->mpRoot == KAVL_NULL) 58 { 59 KAVL_WRITE_UNLOCK(pRoot); 54 60 return 0; 61 } 62 63 #ifdef KAVL_LOOKTHRU 64 /* 65 * Kill the lookthru cache. 66 */ 67 for (i = 0; i < (KAVL_LOOKTHRU); i++) 68 pRoot->maLookthru[i] = KAVL_NULL; 69 #endif 55 70 56 71 cEntries = 1; 57 apEntries[0] = KAVL_GET_POINTER( ppTree);72 apEntries[0] = KAVL_GET_POINTER(&pRoot->mpRoot); 58 73 while (cEntries > 0) 59 74 { … … 80 95 rc = pfnCallBack(pEqual, pvUser); 81 96 if (rc) 97 { 98 KAVL_WRITE_UNLOCK(pRoot); 82 99 return rc; 100 } 83 101 } 84 102 #endif … … 96 114 } 97 115 else 98 *ppTree= KAVL_NULL;116 pRoot->mpRoot = KAVL_NULL; 99 117 100 118 kHlpAssert(pNode->mpLeft == KAVL_NULL); … … 102 120 rc = pfnCallBack(pNode, pvUser); 103 121 if (rc) 122 { 123 KAVL_WRITE_UNLOCK(pRoot); 104 124 return rc; 125 } 105 126 } 106 127 } /* while */ 107 kHlpAssert( *ppTree== KAVL_NULL);128 kHlpAssert(pRoot->mpRoot == KAVL_NULL); 108 129 130 KAVL_WRITE_UNLOCK(pRoot); 109 131 return 0; 110 132 }
Note:
See TracChangeset
for help on using the changeset viewer.

