refactor: Substitute some clunky code with a strdup().

This commit is contained in:
Yash Lala
2022-06-02 17:44:41 -07:00
parent 26284ff627
commit f812275fe6

8
rc.c
View File

@@ -1245,13 +1245,11 @@ do_recursive_mkdir(const char *dir)
size_t n;
struct stat st;
n = strlen(dir);
if (n == 0)
if (*dir == '\0')
return -1;
if ((dircpy = malloc(n + 1)) == NULL)
return -1;
strcpy(dircpy, dir);
if ((dircpy = strdup(dir)) == NULL)
return -1;
ch = dircpy + 1;
do {