rbb         01/03/09 16:07:10

  Modified:    tables   apr_hash.c
  Log:
  Fix a subtle bug in the hash tables.  We can't expand the array after
  finding the entry because if we do, we immediately overwrite the value.
  Intead, we have to expand the hash after setting the value.
  Submitted by: Jon Travis <[EMAIL PROTECTED]>
  Reviewed by:  Ryan Bloom
  
  Revision  Changes    Path
  1.17      +5 -4      apr/tables/apr_hash.c
  
  Index: apr_hash.c
  ===================================================================
  RCS file: /home/cvs/apr/tables/apr_hash.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -d -b -w -u -r1.16 -r1.17
  --- apr_hash.c        2001/03/07 17:57:19     1.16
  +++ apr_hash.c        2001/03/10 00:07:09     1.17
  @@ -275,10 +275,7 @@
       he->klen = klen;
       he->val  = val;
       *hep = he;
  -    /* check that the collision rate isn't too high */
  -    if (++ht->count > ht->max) {
  -     expand_array(ht);
  -    }
  +    ht->count++;
       return hep;
   }
   
  @@ -310,6 +307,10 @@
           else {
               /* replace entry */
               (*hep)->val = val;
  +            /* check that the collision rate isn't too high */
  +            if (ht->count > ht->max) {
  +                expand_array(ht);
  +            }
           }
       }
       /* else key not present and val==NULL */
  
  
  

Reply via email to