#ifndef lint
static char copyright[] =
-"$Id: hash.c,v 1.9.2.1 1998/06/25 21:11:29 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: hash.c,v 1.9.2.2 1999/04/08 21:25:44 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
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;
if (!table)
return;
+ if (!len)
+ len = strlen ((char *)name);
hashno = do_hash (name, len, table -> hash_count);
bp = new_hash_bucket ("add_hash");
if (!table)
return;
+ if (!len)
+ len = strlen ((char *)name);
hashno = do_hash (name, len, table -> hash_count);
return (unsigned char *)0;
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;
+ if (!len)
+ len = strlen ((char *)name);
+
+ 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;
}
-