diff options
author | Shane Kerr <shane@isc.org> | 2006-07-25 10:01:33 +0000 |
---|---|---|
committer | Shane Kerr <shane@isc.org> | 2006-07-25 10:01:33 +0000 |
commit | a3ea21b5c8ae54ba2521745741ef6af79b185633 (patch) | |
tree | cfb3167a9152f293fdeba24a42ebb82a9ce5e36c | |
parent | 65246b46bb0540642a918e10ac72e3fa8ad8338c (diff) | |
download | isc-dhcp-a3ea21b5c8ae54ba2521745741ef6af79b185633.tar.gz |
Re-synching the branch with HEAD fixes.DHCPv6_socket_base
-rw-r--r-- | common/parse.c | 5 | ||||
-rw-r--r-- | includes/omapip/hash.h | 4 | ||||
-rw-r--r-- | omapip/hash.c | 23 |
3 files changed, 24 insertions, 8 deletions
diff --git a/common/parse.c b/common/parse.c index f146d2b1..b1c059e6 100644 --- a/common/parse.c +++ b/common/parse.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.113 2006/07/22 02:24:16 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.113.2.1 2006/07/25 10:01:33 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -991,7 +991,6 @@ parse_option_name (cfile, allocate, known, opt) } /* Look up the actual option info... */ - option = (struct option *)0; option_name_hash_lookup(opt, universe->name_hash, val, 0, MDL); option = *opt; @@ -1765,7 +1764,7 @@ int parse_executable_statement (result, cfile, lose, case_context) const char *val; struct executable_statement base; struct class *cta; - struct option *option; + struct option *option=NULL; struct option_cache *cache; int known; int flag; diff --git a/includes/omapip/hash.h b/includes/omapip/hash.h index 15f2398f..2a588496 100644 --- a/includes/omapip/hash.h +++ b/includes/omapip/hash.h @@ -64,11 +64,13 @@ typedef int (*hash_comparator_t)(const void *, const void *, size_t); struct hash_table { unsigned hash_count; - struct hash_bucket *buckets [DEFAULT_HASH_SIZE]; hash_reference referencer; hash_dereference dereferencer; hash_comparator_t cmp; unsigned (*do_hash)(const void *, unsigned, unsigned); + + /* This must remain the last entry in this table. */ + struct hash_bucket *buckets [1]; }; struct named_hash { diff --git a/omapip/hash.c b/omapip/hash.c index 2d780ccf..ffc2ed92 100644 --- a/omapip/hash.c +++ b/omapip/hash.c @@ -34,7 +34,7 @@ #ifndef lint static char copyright[] = -"$Id: hash.c,v 1.10 2006/06/08 23:51:37 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; +"$Id: hash.c,v 1.10.46.1 2006/07/25 10:01:33 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include <omapip/omapip_p.h> @@ -62,6 +62,7 @@ int new_hash_table (tp, count, file, line) int line; { struct hash_table *rval; + unsigned extra; if (!tp) { log_error ("%s(%d): new_hash_table called with null pointer.", @@ -78,9 +79,18 @@ int new_hash_table (tp, count, file, line) abort (); #endif } - rval = dmalloc (sizeof (struct hash_table) - - (DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *)) + - (count * sizeof (struct hash_bucket *)), file, line); + + /* There is one hash bucket in the structure. Allocate extra + * memory beyond the end of the structure to fulfill the requested + * count ("count - 1"). Do not let there be less than one. + */ + if (count <= 1) + extra = 0; + else + extra = count - 1; + + rval = dmalloc(sizeof(struct hash_table) + + (extra * sizeof(struct hash_bucket *)), file, line); if (!rval) return 0; rval -> hash_count = count; @@ -386,6 +396,11 @@ int hash_lookup (vp, table, key, len, file, line) if (!len) len = find_length(key, table->do_hash); + if (*vp != NULL) { + log_fatal("Internal inconsistency: storage value has not been " + "initialized to zero (from %s:%d).", file, line); + } + hashno = (*table->do_hash)(key, len, table->hash_count); for (bp = table -> buckets [hashno]; bp; bp = bp -> next) { |