libxbps: simplify pkgdb_get_pkgd and find_pkg_dict_installed internals.

There's no need to prop_dictionary_copy the returned dictionary to
later have to free it again, just return directly the dictionary and
avoid the free(3)s.
This commit is contained in:
Juan RP
2012-06-16 09:02:07 +02:00
parent 068cab8d20
commit 974b2fe8ad
19 changed files with 28 additions and 96 deletions

View File

@@ -185,8 +185,6 @@ out:
prop_object_release(filesd);
if (prop_object_type(propsd) == PROP_TYPE_DICTIONARY)
prop_object_release(propsd);
if (prop_object_type(opkgd) == PROP_TYPE_DICTIONARY)
prop_object_release(opkgd);
if (broken)
return 1;

View File

@@ -162,10 +162,8 @@ remove_stale_entries_in_reqby(struct xbps_handle *xhp,
for (i = 0; i < prop_array_count(reqby); i++) {
prop_array_get_cstring_nocopy(reqby, i, &str);
if ((pkgd = xbps_pkgdb_get_pkgd_by_pkgver(xhp, str)) != NULL) {
prop_object_release(pkgd);
if ((pkgd = xbps_pkgdb_get_pkgd_by_pkgver(xhp, str)) != NULL)
continue;
}
printf("%s: found stale entry in requiredby `%s' (fixed)\n",
crd->pkgver, str);
if (xbps_remove_string_from_array(xhp, crd->pkgd_reqby, str))

View File

@@ -76,7 +76,6 @@ show_pkg_reverse_deps(struct xbps_handle *xhp, const char *pkgname)
}
rv = xbps_callback_array_iter_in_dict(xhp, pkgd, "requiredby",
list_strings_sep_in_array, NULL);
prop_object_release(pkgd);
return rv;
}

View File

@@ -89,7 +89,6 @@ state_cb(struct xbps_handle *xhp,
pkgd = xbps_find_pkg_dict_installed(xhp,
xscd->pkgname, false);
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
prop_object_release(pkgd);
printf("Updating `%s' (`%s' to `%s') ...\n", xscd->pkgname,
version, xscd->version);
break;

View File

@@ -337,7 +337,6 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
reqby = prop_dictionary_get(pkgd, "requiredby");
prop_object_release(pkgd);
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
pkgver, prop_array_count(reqby),
prop_array_count(reqby) > 1 ? "S" : "");

View File

@@ -197,7 +197,6 @@ main(int argc, char **argv)
"pkgname", &pkgn);
prop_dictionary_get_cstring_nocopy(pkgd,
"version", &version);
prop_object_release(pkgd);
fprintf(stderr, "%s%s=> ERROR: `%s-%s' is already "
"registered!%s\n", MSG_ERROR,
in_chroot ? "[chroot] " : "",
@@ -251,7 +250,6 @@ main(int argc, char **argv)
}
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
printf("%s\n", version);
prop_object_release(dict);
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
/* Sanitize a plist file (properly indent the file) */
if (argc != 2)