summaryrefslogtreecommitdiff
path: root/lib/libpcap
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpcap')
-rw-r--r--lib/libpcap/optimize.c12
-rw-r--r--lib/libpcap/pcap.c4
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/libpcap/optimize.c b/lib/libpcap/optimize.c
index 3c5fa1eb795..1e52e89bfd4 100644
--- a/lib/libpcap/optimize.c
+++ b/lib/libpcap/optimize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: optimize.c,v 1.12 2006/04/02 21:38:57 djm Exp $ */
+/* $OpenBSD: optimize.c,v 1.13 2007/09/02 15:19:18 deraadt Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
@@ -1806,7 +1806,7 @@ opt_init(root)
*/
unMarkAll();
n = count_blocks(root);
- blocks = (struct block **)malloc(n * sizeof(*blocks));
+ blocks = (struct block **)calloc(n, sizeof(*blocks));
if (blocks == NULL)
bpf_error("malloc");
@@ -1815,14 +1815,14 @@ opt_init(root)
number_blks_r(root);
n_edges = 2 * n_blocks;
- edges = (struct edge **)malloc(n_edges * sizeof(*edges));
+ edges = (struct edge **)calloc(n_edges, sizeof(*edges));
if (edges == NULL)
bpf_error("malloc");
/*
* The number of levels is bounded by the number of nodes.
*/
- levels = (struct block **)malloc(n_blocks * sizeof(*levels));
+ levels = (struct block **)calloc(n_blocks, sizeof(*levels));
if (levels == NULL)
bpf_error("malloc");
@@ -1870,8 +1870,8 @@ opt_init(root)
* we'll need.
*/
maxval = 3 * max_stmts;
- vmap = (struct vmapinfo *)malloc(maxval * sizeof(*vmap));
- vnode_base = (struct valnode *)malloc(maxval * sizeof(*vmap));
+ vmap = (struct vmapinfo *)calloc(maxval, sizeof(*vmap));
+ vnode_base = (struct valnode *)calloc(maxval, sizeof(*vmap));
if (vmap == NULL || vnode_base == NULL)
bpf_error("malloc");
}
diff --git a/lib/libpcap/pcap.c b/lib/libpcap/pcap.c
index 6c516f39e32..9bf613921c0 100644
--- a/lib/libpcap/pcap.c
+++ b/lib/libpcap/pcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcap.c,v 1.10 2006/03/26 20:58:51 djm Exp $ */
+/* $OpenBSD: pcap.c,v 1.11 2007/09/02 15:19:18 deraadt Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998
@@ -209,7 +209,7 @@ pcap_list_datalinks(pcap_t *p, int **dlt_buffer)
**dlt_buffer = p->linktype;
return (1);
} else {
- *dlt_buffer = (int*)malloc(sizeof(**dlt_buffer) * p->dlt_count);
+ *dlt_buffer = (int*)calloc(sizeof(**dlt_buffer), p->dlt_count);
if (*dlt_buffer == NULL) {
(void)snprintf(p->errbuf, sizeof(p->errbuf),
"malloc: %s", pcap_strerror(errno));