2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-30 22:05:23 +00:00

Allocate hash buckets in clumps. Fix a bug in a call to rc_register.

This commit is contained in:
Ted Lemon
2000-06-24 06:16:28 +00:00
parent 40a59753f0
commit c3369c5b53

View File

@@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: alloc.c,v 1.47 2000/05/16 23:02:08 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
"$Id: alloc.c,v 1.48 2000/06/24 06:16:28 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -192,12 +192,27 @@ struct hash_table *new_hash_table (count, file, line)
return rval;
}
struct hash_bucket *free_hash_buckets;
struct hash_bucket *new_hash_bucket (file, line)
const char *file;
int line;
{
struct hash_bucket *rval = dmalloc (sizeof (struct hash_bucket),
file, line);
struct hash_bucket *rval;
int i;
if (!free_hash_buckets) {
rval = dmalloc (127 * sizeof (struct hash_bucket),
file, line);
if (!rval)
return rval;
for (i = 0; i < 127; i++) {
rval -> next = free_hash_buckets;
free_hash_buckets = rval;
rval++;
}
}
rval = free_hash_buckets;
free_hash_buckets = rval -> next;
return rval;
}
@@ -206,7 +221,8 @@ void free_hash_bucket (ptr, file, line)
const char *file;
int line;
{
dfree ((VOIDPTR)ptr, file, line);
ptr -> next = free_hash_buckets;
free_hash_buckets = ptr;
}
struct protocol *new_protocol (file, line)
@@ -755,7 +771,7 @@ int dns_host_entry_dereference (ptr, file, line)
}
(*ptr) -> refcnt--;
rc_register (file, line, ptr, bp, bp -> refcnt);
rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt);
if (!(*ptr) -> refcnt)
dfree ((*ptr), file, line);
if ((*ptr) -> refcnt < 0) {