summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2010-01-01 18:01:45 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2010-01-01 18:01:45 +0000
commitc62b7b6abcece5fda981529542a8a36c86480085 (patch)
treeb09ab7c76ae4b36ae60d86ad7257bf20218e16da /usr.sbin
parentae353120162b72eb79c4702301b7b1121552a2b0 (diff)
Another calloc() wrapper wrapper, new_tree(), bites the dust.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/dhcpd/alloc.c10
-rw-r--r--usr.sbin/dhcpd/dhcpd.h3
-rw-r--r--usr.sbin/dhcpd/tree.c25
3 files changed, 19 insertions, 19 deletions
diff --git a/usr.sbin/dhcpd/alloc.c b/usr.sbin/dhcpd/alloc.c
index a9e31dc4c1e..cd060fb4cff 100644
--- a/usr.sbin/dhcpd/alloc.c
+++ b/usr.sbin/dhcpd/alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alloc.c,v 1.7 2010/01/01 08:02:34 krw Exp $ */
+/* $OpenBSD: alloc.c,v 1.8 2010/01/01 18:01:44 krw Exp $ */
/* Memory allocation... */
@@ -64,14 +64,6 @@ dfree(void *ptr, char *name)
free(ptr);
}
-struct tree *
-new_tree(char *name)
-{
- struct tree *rval = dmalloc(sizeof(struct tree), name);
-
- return (rval);
-}
-
struct tree_cache *free_tree_caches;
struct tree_cache *
diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h
index 0eabebe98d6..949067b0b2c 100644
--- a/usr.sbin/dhcpd/dhcpd.h
+++ b/usr.sbin/dhcpd/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.40 2010/01/01 08:02:34 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.41 2010/01/01 18:01:44 krw Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998, 1999
@@ -604,7 +604,6 @@ void write_leases(void);
/* alloc.c */
void * dmalloc(int, char *);
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 lease_state *new_lease_state(char *);
diff --git a/usr.sbin/dhcpd/tree.c b/usr.sbin/dhcpd/tree.c
index de9ba81b73e..3efde0858ea 100644
--- a/usr.sbin/dhcpd/tree.c
+++ b/usr.sbin/dhcpd/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.11 2006/03/13 19:57:42 otto Exp $ */
+/* $OpenBSD: tree.c,v 1.12 2010/01/01 18:01:44 krw Exp $ */
/* Routines for manipulating parse trees... */
@@ -75,14 +75,20 @@ tree_cache(struct tree *tree)
struct tree *
tree_const(unsigned char *data, int len)
{
- struct tree *nt;
+ unsigned char *d;
+ struct tree *nt;
- if (!(nt = new_tree("tree_const")) || !(nt->data.const_val.data =
- (unsigned char *)dmalloc(len, "tree_const")))
+ d = calloc(1, len);
+ nt = calloc(1, sizeof(struct tree));
+ if (!nt || !d)
error("No memory for constant data tree node.");
+
+ memcpy(d, data, len);
+
nt->op = TREE_CONST;
- memcpy(nt->data.const_val.data, data, len);
+ nt->data.const_val.data = d;
nt->data.const_val.len = len;
+
return nt;
}
@@ -121,7 +127,8 @@ tree_concat(struct tree *left, struct tree *right)
}
/* Otherwise, allocate a new node to concatenate the two. */
- if (!(nt = new_tree("tree_concat")))
+ nt = calloc(1, sizeof(struct tree));
+ if (!nt)
error("No memory for data tree concatenation node.");
nt->op = TREE_CONCAT;
nt->data.concat.left = left;
@@ -142,9 +149,11 @@ tree_limit(struct tree *tree, int limit)
}
/* Otherwise, put in a node which enforces the limit on evaluation. */
- rv = new_tree("tree_limit");
- if (!rv)
+ rv = calloc(1, sizeof(struct tree));
+ if (!rv) {
+ warning("No memory for data tree limit node.");
return NULL;
+ }
rv->op = TREE_LIMIT;
rv->data.limit.tree = tree;
rv->data.limit.limit = limit;