commit | 1ba8a12c4da4439a310864c278e156bce0774537 | [log] [tgz] |
---|---|---|
author | Rob Landley <rob@landley.net> | Tue Mar 22 14:25:46 2022 -0500 |
committer | Rob Landley <rob@landley.net> | Tue Mar 22 14:25:46 2022 -0500 |
tree | 5f6d6281808019486658f810fc69bb3befd5467a | |
parent | 3f7ea911d886343d3f388371f6dad7572428625a [diff] |
Avoid redundant strlen() inside libc.
diff --git a/lib/xwrap.c b/lib/xwrap.c index f16ebe0..65e9f4f 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c
@@ -104,7 +104,12 @@ // Die unless we can allocate a copy of this string. char *xstrdup(char *s) { - return xstrndup(s, strlen(s)); + long len = strlen(s); + char *c = xmalloc(++len); + + memcpy(c, s, len); + + return c; } void *xmemdup(void *s, long len)