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; size_t n;
struct stat st; struct stat st;
n = strlen(dir); if (*dir == '\0')
if (n == 0)
return -1; return -1;
if ((dircpy = malloc(n + 1)) == NULL) if ((dircpy = strdup(dir)) == NULL)
return -1; return -1;
strcpy(dircpy, dir);
ch = dircpy + 1; ch = dircpy + 1;
do { do {