VirtualBox

Ignore:
Timestamp:
Feb 4, 2008 2:08:02 AM (17 years ago)
Author:
bird
Message:

kAVL: Implemented locking, root node and a direct cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/k/kAvlTmpl/kAvlDoWithAll.h

    r2 r7  
    4343    KAVLNODE       *aEntries[KAVL_MAX_STACK];
    4444    char            achFlags[KAVL_MAX_STACK];
     45    KAVLROOT        pRoot;
    4546} KAVL_INT(STACK2);
    4647
     
    5051 *
    5152 * @returns   0 on success. Return from callback on failure.
    52  * @param     ppTree       Pointer to the AVL-tree root node pointer.
     53 * @param     pRoot        Pointer to the AVL-tree root structure.
    5354 * @param     fFromLeft    K_TRUE:  Left to right.
    5455 *                         K_FALSE: Right to left.
     
    5657 * @param     pvUser       User parameter passed on to the callback function.
    5758 */
    58 KAVL_DECL(int) KAVL_FN(DoWithAll)(KAVLTREEPTR *ppTree, KBOOL fFromLeft, KAVL_TYPE(PFN,CALLBACK) pfnCallBack, void *pvUser)
     59KAVL_DECL(int) KAVL_FN(DoWithAll)(KAVLROOT *pRoot, KBOOL fFromLeft, KAVL_TYPE(PFN,CALLBACK) pfnCallBack, void *pvUser)
    5960{
    6061    KAVL_INT(STACK2)    AVLStack;
     
    6566    int                 rc;
    6667
    67     if (*ppTree == KAVL_NULL)
     68    KAVL_READ_LOCK(pRoot);
     69    if (pRoot->mpRoot == KAVL_NULL)
     70    {
     71        KAVL_READ_UNLOCK(pRoot);
    6872        return 0;
     73    }
    6974
    7075    AVLStack.cEntries = 1;
    7176    AVLStack.achFlags[0] = 0;
    72     AVLStack.aEntries[0] = KAVL_GET_POINTER(ppTree);
     77    AVLStack.aEntries[0] = KAVL_GET_POINTER(&pRoot->mpRoot);
    7378
    7479    if (fFromLeft)
     
    99104                    rc = pfnCallBack(pEqual, pvUser);
    100105                    if (rc)
     106                    {
     107                        KAVL_READ_UNLOCK(pRoot);
    101108                        return rc;
     109                    }
    102110                }
    103111#endif
     
    139147                    rc = pfnCallBack(pEqual, pvUser);
    140148                    if (rc)
     149                    {
     150                        KAVL_READ_UNLOCK(pRoot);
    141151                        return rc;
     152                    }
    142153                }
    143154#endif
     
    153164    }
    154165
     166    KAVL_READ_UNLOCK(pRoot);
    155167    return 0;
    156168}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette