]> granicus.if.org Git - graphviz/commitdiff
abbreviate a manual strdup
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 25 May 2021 14:53:55 +0000 (07:53 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 31 May 2021 16:06:24 +0000 (09:06 -0700)
lib/sfio/sftmp.c

index d6fa9b21930803b8e88526ad892816293db6753c..420c63a54cadab52e7245e31c5a0d4b0ab836f83 100644 (file)
@@ -10,6 +10,7 @@
 
 #include       <sfio/sfhdr.h>
 #include       <stddef.h>
+#include       <string.h>
 
 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;