xbps_init: simplify previous and use xbps_xasprintf().

This commit is contained in:
Juan RP 2012-11-19 12:15:32 +01:00
parent b894a5eca3
commit bf2d97a067

View File

@ -171,15 +171,11 @@ xbps_init(struct xbps_handle *xhp)
if (xhp->rootdir[0] != '/') {
/* relative path */
char *buf, path[PATH_MAX-1];
size_t len;
if (getcwd(path, sizeof(path)) == NULL)
return ENOTSUP;
len = strlen(xhp->rootdir) + strlen(path) + 2;
buf = malloc(len);
assert(buf);
snprintf(buf, len, "%s/%s", path, xhp->rootdir);
buf = xbps_xasprintf("%s/%s", path, xhp->rootdir);
xhp->rootdir = buf;
}
}