diff options
author | 2014-06-26 04:03:33 +0000 | |
---|---|---|
committer | 2014-06-26 04:03:33 +0000 | |
commit | b8f389f962b608e4f0bb70079cf589ea15ecd8ef (patch) | |
tree | 7cf5919376b0a7b1aee3e1064c724cb4460cae87 /lib/libpcap/optimize.c | |
parent | Document that VSCSI_I2T is a non-blocking operation and can be (diff) | |
download | wireguard-openbsd-b8f389f962b608e4f0bb70079cf589ea15ecd8ef.tar.xz wireguard-openbsd-b8f389f962b608e4f0bb70079cf589ea15ecd8ef.zip |
Convert several calloc calls to reallocarray. These calloc calls were
originally malloc(n * m) calls (without memset/bzero) in the past.
ok deraadt@ tedu@
Diffstat (limited to 'lib/libpcap/optimize.c')
-rw-r--r-- | lib/libpcap/optimize.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/libpcap/optimize.c b/lib/libpcap/optimize.c index add2fd9da84..16b19f1b67b 100644 --- a/lib/libpcap/optimize.c +++ b/lib/libpcap/optimize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optimize.c,v 1.14 2014/03/16 08:33:05 deraadt Exp $ */ +/* $OpenBSD: optimize.c,v 1.15 2014/06/26 04:03:33 lteo Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 @@ -1810,23 +1810,23 @@ opt_init(root) */ unMarkAll(); n = count_blocks(root); - blocks = (struct block **)calloc(n, sizeof(*blocks)); + blocks = reallocarray(NULL, n, sizeof(*blocks)); if (blocks == NULL) bpf_error("malloc"); - + unMarkAll(); n_blocks = 0; number_blks_r(root); n_edges = 2 * n_blocks; - edges = (struct edge **)calloc(n_edges, sizeof(*edges)); + edges = reallocarray(NULL, n_edges, sizeof(*edges)); if (edges == NULL) bpf_error("malloc"); /* * The number of levels is bounded by the number of nodes. */ - levels = (struct block **)calloc(n_blocks, sizeof(*levels)); + levels = reallocarray(NULL, n_blocks, sizeof(*levels)); if (levels == NULL) bpf_error("malloc"); @@ -1901,8 +1901,8 @@ fail2: * we'll need. */ maxval = 3 * max_stmts; - vmap = (struct vmapinfo *)calloc(maxval, sizeof(*vmap)); - vnode_base = (struct valnode *)calloc(maxval, sizeof(*vmap)); + vmap = reallocarray(NULL, maxval, sizeof(*vmap)); + vnode_base = reallocarray(NULL, maxval, sizeof(*vmap)); if (vmap == NULL || vnode_base == NULL) bpf_error("malloc"); } |