diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-01-01 06:25:38 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-01-01 06:25:38 +0000 |
commit | d8fe5dd71072443fb6506b3fdcae96187f27fcd5 (patch) | |
tree | fe9cd4e753fc63e5e717c8b04073addbfc696f79 /usr.sbin/dhcpd | |
parent | ab953e074000f45ead101cce02ebe325aa4daf41 (diff) |
Single-use wrapper functions that just call a wrapper function
around calloc() and end up producing duplicate error messages are
just confusing.
Eliminate new_hash_bucket(), new_lease(), new_leases(), new_group().
Diffstat (limited to 'usr.sbin/dhcpd')
-rw-r--r-- | usr.sbin/dhcpd/alloc.c | 32 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dhcpd.h | 6 | ||||
-rw-r--r-- | usr.sbin/dhcpd/hash.c | 5 | ||||
-rw-r--r-- | usr.sbin/dhcpd/memory.c | 10 |
4 files changed, 10 insertions, 43 deletions
diff --git a/usr.sbin/dhcpd/alloc.c b/usr.sbin/dhcpd/alloc.c index 69309c0deec..efa7d2a74f4 100644 --- a/usr.sbin/dhcpd/alloc.c +++ b/usr.sbin/dhcpd/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.5 2010/01/01 01:47:41 krw Exp $ */ +/* $OpenBSD: alloc.c,v 1.6 2010/01/01 06:25:37 krw Exp $ */ /* Memory allocation... */ @@ -104,14 +104,6 @@ new_hash_table(int count, char *name) return (rval); } -struct hash_bucket * -new_hash_bucket(char *name) -{ - struct hash_bucket *rval = dmalloc(sizeof(struct hash_bucket), name); - - return (rval); -} - void free_hash_bucket(struct hash_bucket *ptr, char *name) { @@ -169,28 +161,6 @@ free_lease_state(struct lease_state *ptr, char *name) free_lease_states = ptr; } -struct lease * -new_leases(int n, char *name) -{ - struct lease *rval = dmalloc(n * sizeof(struct lease), name); - return (rval); -} - -struct lease * -new_lease(char *name) -{ - struct lease *rval = dmalloc(sizeof(struct lease), name); - return (rval); -} - -struct group * -new_group(char *name) -{ - struct group *rval = - dmalloc(sizeof(struct group), name); - return (rval); -} - void free_lease(struct lease *ptr, char *name) { diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h index 937e779af92..9454462ef99 100644 --- a/usr.sbin/dhcpd/dhcpd.h +++ b/usr.sbin/dhcpd/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.38 2010/01/01 02:38:02 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.39 2010/01/01 06:25:37 krw Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -607,12 +607,8 @@ void dfree(void *, char *); struct tree *new_tree(char *); struct tree_cache *new_tree_cache(char *); struct hash_table *new_hash_table(int, char *); -struct hash_bucket *new_hash_bucket(char *); -struct lease *new_lease(char *); -struct lease *new_leases(int, char *); struct subnet *new_subnet(char *); struct shared_network *new_shared_network(char *); -struct group *new_group(char *); struct lease_state *new_lease_state(char *); void free_lease_state(struct lease_state *, char *); void free_lease(struct lease *, char *); diff --git a/usr.sbin/dhcpd/hash.c b/usr.sbin/dhcpd/hash.c index ea2cdac3a9b..cfecb903b54 100644 --- a/usr.sbin/dhcpd/hash.c +++ b/usr.sbin/dhcpd/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.3 2004/09/16 18:35:43 deraadt Exp $ */ +/* $OpenBSD: hash.c,v 1.4 2010/01/01 06:25:37 krw Exp $ */ /* Routines for manipulating hash tables... */ @@ -84,8 +84,7 @@ void add_hash(struct hash_table *table, unsigned char *name, int len, len = strlen((char *)name); hashno = do_hash(name, len, table->hash_count); - bp = new_hash_bucket("add_hash"); - + bp = calloc(1, sizeof(struct hash_bucket)); if (!bp) { warning("Can't add %s to hash table.", name); return; diff --git a/usr.sbin/dhcpd/memory.c b/usr.sbin/dhcpd/memory.c index 4f83535008e..d7c6fbbe500 100644 --- a/usr.sbin/dhcpd/memory.c +++ b/usr.sbin/dhcpd/memory.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memory.c,v 1.17 2010/01/01 01:47:41 krw Exp $ */ +/* $OpenBSD: memory.c,v 1.18 2010/01/01 06:25:37 krw Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. @@ -228,7 +228,7 @@ new_address_range(struct iaddr low, struct iaddr high, struct subnet *subnet, } /* Get a lease structure for each address in the range. */ - address_range = new_leases(max - min + 1, "new_address_range"); + address_range = calloc(max - min + 1, sizeof(struct lease)); if (!address_range) { strlcpy(lowbuf, piaddr(low), sizeof(lowbuf)); strlcpy(highbuf, piaddr(high), sizeof(highbuf)); @@ -411,7 +411,7 @@ enter_lease(struct lease *lease) /* If we don't have a place for this lease yet, save it for later. */ if (!comp) { - comp = new_lease("enter_lease"); + comp = calloc(1, sizeof(struct lease)); if (!comp) error("No memory for lease %s\n", piaddr(lease->ip_addr)); @@ -834,7 +834,9 @@ find_class(int type, unsigned char *name, int len) struct group * clone_group(struct group *group, char *caller) { - struct group *g = new_group(caller); + struct group *g; + + g = calloc(1, sizeof(struct group)); if (!g) error("%s: can't allocate new group", caller); *g = *group; |