aboutsummaryrefslogtreecommitdiff
path: root/miscutils
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 /miscutils
parent78cfa00154dca18a1326d2064121bf65cd081781 (diff)
downloadbusybox-w32-d840c5d139cfa50fbe4f6f67c178b0edf0c690c8.tar.gz
busybox-w32-d840c5d139cfa50fbe4f6f67c178b0edf0c690c8.tar.bz2
busybox-w32-d840c5d139cfa50fbe4f6f67c178b0edf0c690c8.zip
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 'miscutils')
-rw-r--r--miscutils/last_fancy.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c
index 8194e31b5..e56e0ba85 100644
--- a/miscutils/last_fancy.c
+++ b/miscutils/last_fancy.c
@@ -233,7 +233,7 @@ int last_main(int argc UNUSED_PARAM, char **argv)
233 break; 233 break;
234 } 234 }
235 /* add_entry */ 235 /* add_entry */
236 llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut))); 236 llist_add_to(&zlist, xmemdup(&ut, sizeof(ut)));
237 break; 237 break;
238 case USER_PROCESS: { 238 case USER_PROCESS: {
239 int show; 239 int show;
@@ -275,7 +275,7 @@ int last_main(int argc UNUSED_PARAM, char **argv)
275 show_entry(&ut, state, boot_time); 275 show_entry(&ut, state, boot_time);
276 } 276 }
277 /* add_entry */ 277 /* add_entry */
278 llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut))); 278 llist_add_to(&zlist, xmemdup(&ut, sizeof(ut)));
279 break; 279 break;
280 } 280 }
281 } 281 }