}
int do_mkdir(const char *path, mode_t mode) {
+ char d[PATH_MAX];
size_t s, l;
- int p;
- int r;
+ int r, p;
assert(path);
l = strlen(path);
- for (p = 0, s = 0; p < l; p += s+1) {
- _cleanup_free_ char *d = NULL;
-
- s = strcspn(path+p, "/");
+ for (p = 0, s = 0; p < l; p += s + 1) {
+ s = strcspn(path + p, "/");
if (!s)
continue;
- d = new0(char, p+s+1);
- if (!d)
- return -ENOMEM;
+ assert(PATH_MAX > p + s + 1);
- r = snprintf(d, p+s+1, "%s", path);
+ r = snprintf(d, p + s + 1, "%s", path);
if (r < 0)
return r;