Changeset 744

Show
Ignore:
Timestamp:
05/06/07 19:02:23 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

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

    r732 r744  
     12007-05-06  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * cherokee/table.c (cherokee_table_add), 
     4        cherokee/avl.c (avl_insert_by_key): Return ret_deny if it tries to 
     5        insert an element that was already on the table. Until now, it was 
     6        just ignoring the operation while it was returning 
     7        ret_ok. Obviously it was wrong. This change may have some unwanted 
     8        side effects, stay tuned. 
     9 
    1102007-04-30  A.D.F  <adefacc@tin.it> 
    211 
  • cherokee/trunk/cherokee/avl.c

    r446 r744  
    132132                avl_node *t, *p, *s, *q, *r; 
    133133                int a; 
     134                int cmpa; 
    134135                *index = 0; 
    135136 
     
    138139 
    139140                while (1) { 
    140                         if (ob->compare_fun (ob->compare_arg, key, p->key) < 1) { 
     141                        cmpa = ob->compare_fun (ob->compare_arg, key, p->key); 
     142                        if (cmpa == 0) { 
     143                                /* The element is already in the tree 
     144                                 */ 
     145                                return -2; 
     146                        } else if (cmpa < 1) { 
    141147                                /* move left */ 
    142148                                AVL_SET_RANK (p, (AVL_GET_RANK (p) + 1)); 
     
    146152                                        avl_node * q_node = avl_new_avl_node (key, value, p); 
    147153                                        if (!q_node) { 
    148                                                 return (-1)
     154                                                return -1
    149155                                        } else { 
    150156                                                q = q_node; 
  • cherokee/trunk/cherokee/table.c

    r597 r744  
    143143 
    144144        re = avl_insert_by_key (tab, strdup(key), value, &index); 
    145         if (unlikely (re != 0)) return ret_error; 
     145        if (unlikely (re != 0)) { 
     146                switch (re) { 
     147                case -2: 
     148                        return ret_deny; 
     149                default: 
     150                        return ret_error; 
     151                } 
     152        } 
    146153 
    147154        return ret_ok;