Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/usr.sbin/dhcp/common Pull up 1.1.1.3 (patchlevel 25)



details:   https://anonhg.NetBSD.org/src/rev/458f97991b85
branches:  netbsd-1-4
changeset: 468150:458f97991b85
user:      mellon <mellon%NetBSD.org@localhost>
date:      Fri Apr 09 20:07:24 1999 +0000

description:
Pull up 1.1.1.3 (patchlevel 25)

diffstat:

 usr.sbin/dhcp/common/hash.c |  47 +++++++++++++++++---------------------------
 1 files changed, 18 insertions(+), 29 deletions(-)

diffs (87 lines):

diff -r 233ebf50fac1 -r 458f97991b85 usr.sbin/dhcp/common/hash.c
--- a/usr.sbin/dhcp/common/hash.c       Fri Apr 09 20:07:10 1999 +0000
+++ b/usr.sbin/dhcp/common/hash.c       Fri Apr 09 20:07:24 1999 +0000
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: hash.c,v 1.1.1.2 1999/02/18 21:48:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: hash.c,v 1.1.1.2.2.1 1999/04/09 20:07:24 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -67,23 +67,12 @@
        register int accum = 0;
        register unsigned char *s = name;
        int i = len;
-       if (i) {
-               while (i--) {
-                       /* Add the character in... */
-                       accum += *s++;
-                       /* Add carry back in... */
-                       while (accum > 255) {
-                               accum = (accum & 255) + (accum >> 8);
-                       }
-               }
-       } else {
-               while (*s) {
-                       /* Add the character in... */
-                       accum += *s++;
-                       /* Add carry back in... */
-                       while (accum > 255) {
-                               accum = (accum & 255) + (accum >> 8);
-                       }
+       while (i--) {
+               /* Add the character in... */
+               accum += *s++;
+               /* Add carry back in... */
+               while (accum > 255) {
+                       accum = (accum & 255) + (accum >> 8);
                }
        }
        return accum % size;
@@ -100,6 +89,8 @@
 
        if (!table)
                return;
+       if (!len)
+               len = strlen ((char *)name);
 
        hashno = do_hash (name, len, table -> hash_count);
        bp = new_hash_bucket ("add_hash");
@@ -125,6 +116,8 @@
 
        if (!table)
                return;
+       if (!len)
+               len = strlen ((char *)name);
 
        hashno = do_hash (name, len, table -> hash_count);
 
@@ -157,19 +150,15 @@
 
        if (!table)
                return (unsigned char *)0;
+
+       if (!len)
+               len = strlen ((char *)name);
+
        hashno = do_hash (name, len, table -> hash_count);
 
-       if (len) {
-               for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
-                       if (len == bp -> len
-                           && !memcmp (bp -> name, name, len))
-                               return bp -> value;
-               }
-       } else {
-               for (bp = table -> buckets [hashno]; bp; bp = bp -> next)
-                       if (!strcmp ((char *)bp -> name, (char *)name))
-                               return bp -> value;
+       for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
+               if (len == bp -> len && !memcmp (bp -> name, name, len))
+                       return bp -> value;
        }
        return (unsigned char *)0;
 }
-



Home | Main Index | Thread Index | Old Index