Changeset 836

Show
Ignore:
Timestamp:
07/17/07 18:08:48 (1 year ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r835 r836  
    112007-07-17  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * cherokee/avl.c (cherokee_avl_mrproper): Implemented. 
    24 
    35        * qa/run-tests.py: Count down fixed. 
  • cherokee/trunk/cherokee/avl.c

    r835 r836  
    4343 
    4444 
     45static cherokee_avl_node_t *node_first (cherokee_avl_t *avl); 
     46static cherokee_avl_node_t *node_prev  (cherokee_avl_node_t *node); 
     47static cherokee_avl_node_t *node_next  (cherokee_avl_node_t *node); 
     48 
     49 
    4550/* Nodes 
    4651 */ 
     
    8489 
    8590 
    86 static ret_t 
    87 mrproper2_while (cherokee_buffer_t *key, void *value, void *param) 
    88 { 
    89         cherokee_avl_value_free_func_t free_func = param; 
    90  
    91         if (free_func) { 
    92                 free_func(value); 
    93         } 
    94  
    95         return ret_ok; 
    96 } 
    97  
    9891ret_t  
    9992cherokee_avl_mrproper (cherokee_avl_t *avl, cherokee_avl_value_free_func_t free_func) 
    10093{ 
    101         /* Free all the entries 
    102          */ 
    103         cherokee_avl_while (avl, mrproper2_while, free_func, NULL, NULL); 
    104  
    105         /* Clean the entries as well 
    106          */ 
    107 //      TODO ! 
     94        cherokee_avl_node_t *node; 
     95        cherokee_avl_node_t *next; 
     96 
     97        node = node_first (avl); 
     98   
     99        while (node) { 
     100                next = node_next (node); 
     101 
     102                cherokee_buffer_mrproper (&node->id); 
     103                if (free_func) 
     104                        free_func (node->value); 
     105 
     106                free (node); 
     107                node = next; 
     108        } 
    108109 
    109110        return ret_ok; 
     
    150151 
    151152static cherokee_avl_node_t * 
     153node_first (cherokee_avl_t *avl) 
     154{ 
     155        cherokee_avl_node_t *tmp; 
     156 
     157        if (!avl->root) 
     158                return NULL; 
     159 
     160        tmp = avl->root; 
     161 
     162        while (tmp->left_child) 
     163                tmp = tmp->left; 
     164 
     165        return tmp; 
     166} 
     167 
     168static cherokee_avl_node_t * 
     169node_next (cherokee_avl_node_t *node) 
     170{ 
     171        cherokee_avl_node_t *tmp = node->right; 
     172 
     173        if (node->right_child) 
     174                while (tmp->left_child) 
     175                        tmp = tmp->left; 
     176        return tmp; 
     177} 
     178 
     179static cherokee_avl_node_t * 
    152180node_prev (cherokee_avl_node_t *node) 
    153181{ 
     
    160188} 
    161189 
    162 static cherokee_avl_node_t * 
    163 node_first (cherokee_avl_t *avl) 
    164 { 
    165         cherokee_avl_node_t *tmp; 
    166  
    167         if (!avl->root) 
    168                 return NULL; 
    169  
    170         tmp = avl->root; 
    171  
    172         while (tmp->left_child) 
    173                 tmp = tmp->left; 
    174  
    175         return tmp; 
    176 } 
    177  
    178 static cherokee_avl_node_t * 
    179 node_next (cherokee_avl_node_t *node) 
    180 { 
    181         cherokee_avl_node_t *tmp = node->right; 
    182  
    183         if (node->right_child) 
    184                 while (tmp->left_child) 
    185                         tmp = tmp->left; 
    186         return tmp; 
    187 } 
    188190 
    189191static cherokee_avl_node_t *