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>
This commit is contained in:
committed by
Denys Vlasenko
parent
78cfa00154
commit
d840c5d139
@ -673,6 +673,7 @@ uint16_t inet_cksum(uint16_t *addr, int len) FAST_FUNC;
|
||||
|
||||
char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
|
||||
char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC;
|
||||
void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC;
|
||||
void overlapping_strcpy(char *dst, const char *src) FAST_FUNC;
|
||||
char *safe_strncpy(char *dst, const char *src, size_t size) FAST_FUNC;
|
||||
char *strncpy_IFNAMSIZ(char *dst, const char *src) FAST_FUNC;
|
||||
|
Reference in New Issue
Block a user