From: Matthew Fernandez Date: Tue, 25 May 2021 14:53:55 +0000 (-0700) Subject: abbreviate a manual strdup X-Git-Tag: 2.47.3~20^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=969a7cdeba64342cc4b23852db91b7a0465ae4e9;p=graphviz abbreviate a manual strdup --- diff --git a/lib/sfio/sftmp.c b/lib/sfio/sftmp.c index d6fa9b219..420c63a54 100644 --- a/lib/sfio/sftmp.c +++ b/lib/sfio/sftmp.c @@ -10,6 +10,7 @@ #include #include +#include char **_sfgetpath(char *path) { @@ -30,11 +31,10 @@ char **_sfgetpath(char *path) } if (n == 0 || !(dirs = malloc((n + 1) * sizeof(char *)))) return NULL; - if (!(p = malloc(strlen(path) + 1))) { + if (!(p = strdup(path))) { free(dirs); return NULL; } - strcpy(p, path); for (n = 0;; ++n) { while (*p == ':') ++p;