aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mdev.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@frippery.org>2015-07-19 23:05:20 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-07-19 23:05:20 +0200
commitd840c5d139cfa50fbe4f6f67c178b0edf0c690c8 (patch)
treee75010ca3ce7769f53a6170ebe940f37c6a94dc1 /util-linux/mdev.c
parent78cfa00154dca18a1326d2064121bf65cd081781 (diff)
downloadbusybox-d840c5d139cfa50fbe4f6f67c178b0edf0c690c8.tar.gz
libbb: add a function to make a copy of a region of memory
Introduce a library routine to package the idiom: p = xmalloc(b, n); memcpy(p, b, n); and use it where possible. The example in traceroute used xzalloc but it didn't need to. function old new delta xmemdup - 32 +32 last_main 834 826 -8 make_device 2321 2311 -10 common_traceroute_main 3698 3685 -13 readtoken1 3182 3168 -14 procps_scan 1222 1206 -16 forkchild 655 638 -17 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78) Total: -46 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r--util-linux/mdev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index ca4b91510..662e8ab38 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -471,7 +471,7 @@ static const struct rule *next_rule(void)
if (G.parser) {
parse_next_rule();
if (G.rule_vec) { /* mdev -s */
- rule = memcpy(xmalloc(sizeof(G.cur_rule)), &G.cur_rule, sizeof(G.cur_rule));
+ rule = xmemdup(&G.cur_rule, sizeof(G.cur_rule));
G.rule_vec = xrealloc_vector(G.rule_vec, 4, G.rule_idx);
G.rule_vec[G.rule_idx++] = rule;
dbg3("> G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);