diff options
| author | 2010-01-02 04:21:16 +0000 | |
|---|---|---|
| committer | 2010-01-02 04:21:16 +0000 | |
| commit | d60fc4a49ba5bfd05a3b09e715a328032ca8a26c (patch) | |
| tree | 4f19ae42780699a1e61c5605aae297d2b13c6448 /usr.sbin/dhcpd/alloc.c | |
| parent | complete the sync to 1.9.15-pre2: mostly minor fixes (diff) | |
| download | wireguard-openbsd-d60fc4a49ba5bfd05a3b09e715a328032ca8a26c.tar.xz wireguard-openbsd-d60fc4a49ba5bfd05a3b09e715a328032ca8a26c.zip | |
Eliminate all uses of dmalloc() where the returned pointer
is checked for NULL and a specific error/warning issued. Add
two such manual warning/error checks and kill those dmalloc
calls. And then there were none, so kill dmalloc(). Whew.
Diffstat (limited to 'usr.sbin/dhcpd/alloc.c')
| -rw-r--r-- | usr.sbin/dhcpd/alloc.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/usr.sbin/dhcpd/alloc.c b/usr.sbin/dhcpd/alloc.c index f3306f87cb2..6b8f0069738 100644 --- a/usr.sbin/dhcpd/alloc.c +++ b/usr.sbin/dhcpd/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.11 2010/01/01 20:46:19 krw Exp $ */ +/* $OpenBSD: alloc.c,v 1.12 2010/01/02 04:21:16 krw Exp $ */ /* Memory allocation... */ @@ -43,17 +43,6 @@ #include "dhcpd.h" struct lease_state *free_lease_states; - -void * -dmalloc(int size, char *name) -{ - void *foo = calloc(size, sizeof(char)); - - if (!foo) - warning("No memory for %s.", name); - return (foo); -} - struct tree_cache *free_tree_caches; struct tree_cache * @@ -65,7 +54,7 @@ new_tree_cache(char *name) rval = free_tree_caches; free_tree_caches = (struct tree_cache *)(rval->value); } else { - rval = dmalloc(sizeof(struct tree_cache), name); + rval = calloc(1, sizeof(struct tree_cache)); if (!rval) error("unable to allocate tree cache for %s.", name); } @@ -86,10 +75,13 @@ new_lease_state(char *name) if (free_lease_states) { rval = free_lease_states; - free_lease_states = - (struct lease_state *)(free_lease_states->next); - } else - rval = dmalloc (sizeof (struct lease_state), name); + free_lease_states = free_lease_states->next; + } else { + rval = calloc(1, sizeof(struct lease_state)); + if (!rval) + error("unable to allocate lease state for %s.", name); + } + return (rval); } |
