Introduce xbps_xasprintf() and use it where required.
--HG-- extra : convert_revision : 324a92a4824476059e0993d00c2b925c732a79f8
This commit is contained in:
parent
f5dd58df5d
commit
4bf5c5f750
14 changed files with 108 additions and 175 deletions
|
@ -181,24 +181,15 @@ int
|
|||
show_pkg_info_from_metadir(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
size_t len = 0;
|
||||
char *plist, *path;
|
||||
const char *rootdir;
|
||||
char *plist;
|
||||
|
||||
/* XBPS_META_PATH/metadata/<pkgname> + NULL */
|
||||
len = strlen(XBPS_META_PATH) + strlen(pkgname) + 12;
|
||||
path = malloc(len);
|
||||
if (path == NULL)
|
||||
rootdir = xbps_get_rootdir();
|
||||
plist = xbps_xasprintf("%s/%s/metadata/%s/%s", rootdir,
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
(void)snprintf(path, len, "%s/metadata/%s", XBPS_META_PATH, pkgname);
|
||||
|
||||
plist = xbps_append_full_path(true, path, XBPS_PKGPROPS);
|
||||
if (plist == NULL) {
|
||||
free(path);
|
||||
return EINVAL;
|
||||
}
|
||||
free(path);
|
||||
|
||||
pkgd = prop_dictionary_internalize_from_file(plist);
|
||||
if (pkgd == NULL) {
|
||||
free(plist);
|
||||
|
@ -217,27 +208,15 @@ show_pkg_files_from_metadir(const char *pkgname, bool hash)
|
|||
{
|
||||
prop_dictionary_t pkgd;
|
||||
struct show_files_cb sfc;
|
||||
size_t len = 0;
|
||||
const char *destdir = xbps_get_rootdir();
|
||||
char *plist, *path;
|
||||
char *plist;
|
||||
int rv = 0;
|
||||
|
||||
/* XBPS_META_PATH/metadata/<pkgname>/XBPS_PKGFILES + NULL */
|
||||
len = strlen(XBPS_META_PATH) + strlen(pkgname) +
|
||||
strlen(XBPS_PKGFILES) + 12;
|
||||
path = malloc(len);
|
||||
if (path == NULL)
|
||||
plist = xbps_xasprintf("%s/%s/metadata/%s/%s", destdir,
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
(void)snprintf(path, len, "%s/metadata/%s", XBPS_META_PATH, pkgname);
|
||||
|
||||
plist = xbps_append_full_path(true, path, XBPS_PKGFILES);
|
||||
if (plist == NULL) {
|
||||
free(path);
|
||||
return EINVAL;
|
||||
}
|
||||
free(path);
|
||||
|
||||
pkgd = prop_dictionary_internalize_from_file(plist);
|
||||
if (pkgd == NULL) {
|
||||
free(plist);
|
||||
|
@ -277,7 +256,7 @@ show_pkg_files(prop_object_t obj, void *arg, bool *loop_done)
|
|||
if (sfc->check_hash && file != NULL) {
|
||||
printf("%s", file);
|
||||
if (sfc->destdir) {
|
||||
path = xbps_append_full_path(false, sfc->destdir, file);
|
||||
path = xbps_xasprintf("%s/%s", sfc->destdir, file);
|
||||
if (path == NULL)
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue