]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Make the hash functions work usefully for hash table sizes >255.
authorTed Lemon <source@isc.org>
Sat, 24 Jun 2000 06:19:13 +0000 (06:19 +0000)
committerTed Lemon <source@isc.org>
Sat, 24 Jun 2000 06:19:13 +0000 (06:19 +0000)
common/hash.c

index 0588a150e1131415d84f93d30ba6052f51a07fed..371b0e03fc987fa3f18f07b50d7cacaf200d9069 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: hash.c,v 1.24 2000/06/06 23:46:31 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: hash.c,v 1.25 2000/06/24 06:19:13 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -90,10 +90,11 @@ static int do_case_hash (name, len, size)
                        c = tolower (c);
 
                /* Add the character in... */
-               accum += c;
+               accum = (accum << 1) + c;
+
                /* Add carry back in... */
-               while (accum > 255) {
-                       accum = (accum & 255) + (accum >> 8);
+               while (accum > 65535) {
+                       accum = (accum & 65535) + (accum >> 16);
                }
        }
        return accum % size;
@@ -110,10 +111,11 @@ static int do_hash (name, len, size)
 
        while (i--) {
                /* Add the character in... */
-               accum += *s++;
+               accum = (accum << 1) + *s++;
+
                /* Add carry back in... */
-               while (accum > 255) {
-                       accum = (accum & 255) + (accum >> 8);
+               while (accum > 65535) {
+                       accum = (accum & 65535) + (accum >> 16);
                }
        }
        return accum % size;