From: Ted Lemon Date: Mon, 5 Apr 1999 19:02:42 +0000 (+0000) Subject: If the length of a hash name is zero, compute it with strlen. X-Git-Tag: V3-ALPHA-19990408~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=480362714ed09b6e049c3c7c05c30071bfbc3a40;p=thirdparty%2Fdhcp.git If the length of a hash name is zero, compute it with strlen. --- diff --git a/common/hash.c b/common/hash.c index 7a303503d..8fa51e69d 100644 --- a/common/hash.c +++ b/common/hash.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: hash.c,v 1.12 1999/03/16 05:50:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: hash.c,v 1.13 1999/04/05 19:02:42 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -81,6 +81,9 @@ void add_hash (table, name, len, pointer) if (!table) return; + if (!len) + len = strlen (name); + hashno = do_hash (name, len, table -> hash_count); bp = new_hash_bucket ("add_hash"); @@ -106,6 +109,9 @@ void delete_hash_entry (table, name, len) if (!table) return; + if (!len) + len = strlen (name); + hashno = do_hash (name, len, table -> hash_count); /* Go through the list looking for an entry that matches; @@ -137,19 +143,15 @@ unsigned char *hash_lookup (table, name, len) if (!table) return (unsigned char *)0; + if (!len) + len = strlen (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; }