apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/tables apr_hash.c
Date Sat, 10 Mar 2001 00:07:10 GMT
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 <jtravis@covalent.net>
  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 */
  
  
  

Mime
View raw message