xbps_init: simplify previous and use xbps_xasprintf().
This commit is contained in:
parent
b894a5eca3
commit
bf2d97a067
@ -171,15 +171,11 @@ xbps_init(struct xbps_handle *xhp)
|
|||||||
if (xhp->rootdir[0] != '/') {
|
if (xhp->rootdir[0] != '/') {
|
||||||
/* relative path */
|
/* relative path */
|
||||||
char *buf, path[PATH_MAX-1];
|
char *buf, path[PATH_MAX-1];
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (getcwd(path, sizeof(path)) == NULL)
|
if (getcwd(path, sizeof(path)) == NULL)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
|
||||||
len = strlen(xhp->rootdir) + strlen(path) + 2;
|
buf = xbps_xasprintf("%s/%s", path, xhp->rootdir);
|
||||||
buf = malloc(len);
|
|
||||||
assert(buf);
|
|
||||||
snprintf(buf, len, "%s/%s", path, xhp->rootdir);
|
|
||||||
xhp->rootdir = buf;
|
xhp->rootdir = buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user