#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.114 2006/07/25 09:59:39 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
}
/* Look up the actual option info... */
- option = (struct option *)0;
option_name_hash_lookup(opt, universe->name_hash, val, 0, MDL);
option = *opt;
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;
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 {
#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.11 2006/07/25 09:59:39 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include <omapip/omapip_p.h>
int line;
{
struct hash_table *rval;
+ unsigned extra;
if (!tp) {
log_error ("%s(%d): new_hash_table called with null pointer.",
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;
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) {