diff --git a/bin/xbps-bin/check.c b/bin/xbps-bin/check.c index a0c9314f..ce8e6c62 100644 --- a/bin/xbps-bin/check.c +++ b/bin/xbps-bin/check.c @@ -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; diff --git a/bin/xbps-bin/check_pkg_requiredby.c b/bin/xbps-bin/check_pkg_requiredby.c index 521a7958..fdaefebf 100644 --- a/bin/xbps-bin/check_pkg_requiredby.c +++ b/bin/xbps-bin/check_pkg_requiredby.c @@ -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)) diff --git a/bin/xbps-bin/show-deps.c b/bin/xbps-bin/show-deps.c index 4d71fd04..4a050065 100644 --- a/bin/xbps-bin/show-deps.c +++ b/bin/xbps-bin/show-deps.c @@ -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; } diff --git a/bin/xbps-bin/state_cb.c b/bin/xbps-bin/state_cb.c index a9b07e0b..217c0a56 100644 --- a/bin/xbps-bin/state_cb.c +++ b/bin/xbps-bin/state_cb.c @@ -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; diff --git a/bin/xbps-bin/transaction.c b/bin/xbps-bin/transaction.c index 0cf6bc92..e31c5626 100644 --- a/bin/xbps-bin/transaction.c +++ b/bin/xbps-bin/transaction.c @@ -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" : ""); diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 607d0b35..76da163a 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -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) diff --git a/include/xbps_api.h b/include/xbps_api.h index d337d480..18721e39 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.5" -#define XBPS_API_VERSION "20120615" +#define XBPS_API_VERSION "20120616" #define XBPS_VERSION "0.16" /** @@ -714,9 +714,7 @@ int xbps_pkgdb_foreach_reverse_cb( * @param[in] bypattern If false \a pkg must be a pkgname, otherwise a * package pattern, i.e `foo>=0' or `foo<1'. * - * @return The matching proplib package dictionary from pkgdb copied - * with \a prop_dictionary_copy() so it must be released when not required - * anymore with prop_object_release(). NULL otherwise. + * @return The matching proplib package dictionary, NULL otherwise. */ prop_dictionary_t xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, const char *pkg, @@ -729,9 +727,7 @@ prop_dictionary_t xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, * @param[in] xhp The pointer to the xbps_handle struct. * @param[in] pkgver Package name-version to match, i.e 'foo-1.0'. * - * @return The matching proplib package dictionary from pkgdb copied - * with \a prop_dictionary_copy() so it must be released when not required - * anymore with prop_object_release(). NULL otherwise. + * @return The matching proplib package dictionary, NULL otherwise. */ prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver); @@ -1002,8 +998,6 @@ prop_dictionary_t xbps_find_virtualpkg_in_dict_by_pattern(struct xbps_handle *xh * * @return The package's dictionary on success, NULL otherwise and * errno is set appropiately. - * @note When returned dictionary is no longer needed, it must be released - * with prop_object_release(3). */ prop_dictionary_t xbps_find_pkg_dict_installed(struct xbps_handle *xhp, const char *str, @@ -1021,8 +1015,6 @@ prop_dictionary_t xbps_find_pkg_dict_installed(struct xbps_handle *xhp, * * @return The virtual package's dictionary on success, NULL otherwise and * errno is set appropiately. - * @note When returned dictionary is no longer needed, it must be released - * with prop_object_release(3). */ prop_dictionary_t xbps_find_virtualpkg_dict_installed(struct xbps_handle *xhp, const char *str, diff --git a/lib/package_configure.c b/lib/package_configure.c index e68e2e00..fe497622 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -103,16 +103,11 @@ xbps_configure_pkg(struct xbps_handle *xhp, } if (state == XBPS_PKG_STATE_INSTALLED) { - if ((xhp->flags & XBPS_FLAG_FORCE_CONFIGURE) == 0) { - prop_object_release(pkgd); + if ((xhp->flags & XBPS_FLAG_FORCE_CONFIGURE) == 0) return 0; - } - } else if (state != XBPS_PKG_STATE_UNPACKED) { - prop_object_release(pkgd); + } else if (state != XBPS_PKG_STATE_UNPACKED) return EINVAL; - } } - prop_object_release(pkgd); xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE, 0, pkgname, version, NULL); buf = xbps_xasprintf("%s/metadata/%s/INSTALL", diff --git a/lib/package_conflicts.c b/lib/package_conflicts.c index 8ca32d5b..df34aa87 100644 --- a/lib/package_conflicts.c +++ b/lib/package_conflicts.c @@ -59,7 +59,6 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod) "installed pkg %s", repopkgver, pkgver); assert(buf != NULL); prop_array_add_cstring(trans_cflicts, buf); - prop_object_release(pkgd); free(buf); continue; } diff --git a/lib/package_register.c b/lib/package_register.c index b23d6850..94a46c9f 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -137,9 +137,6 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd, bool flush) goto out; } out: - if (pkgd != NULL) - prop_object_release(pkgd); - if (rv != 0) { xbps_set_cb_state(xhp, XBPS_STATE_REGISTER_FAIL, rv, pkgname, version, diff --git a/lib/package_state.c b/lib/package_state.c index 7a42ceaa..a502c124 100644 --- a/lib/package_state.c +++ b/lib/package_state.c @@ -107,7 +107,6 @@ xbps_pkg_state_installed(struct xbps_handle *xhp, return ENOENT; *state = get_state(pkgd); - prop_object_release(pkgd); if (*state == 0) return EINVAL; @@ -203,11 +202,8 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp, if (pkgd == NULL) { newpkg = true; pkgd = prop_dictionary_create(); - rv = set_pkg_objs(pkgd, pkgname, version); - if (rv != 0) { - prop_object_release(pkgd); + if ((rv = set_pkg_objs(pkgd, pkgname, version)) != 0) return rv; - } } if ((rv = set_new_state(pkgd, state)) != 0) { if (newpkg) @@ -223,8 +219,6 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp, if ((rv = xbps_array_replace_dict_by_name(xhp->pkgdb, pkgd, pkgname)) != 0) return rv; - - prop_object_release(pkgd); } } diff --git a/lib/pkgdb.c b/lib/pkgdb.c index 1849f515..aded4841 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -169,25 +169,16 @@ xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, const char *pkg, bool bypattern) else pkgd = xbps_find_pkg_in_array_by_name(xhp, xhp->pkgdb, pkg, NULL); - if (pkgd != NULL) - return prop_dictionary_copy(pkgd); - - return NULL; + return pkgd; } prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver) { - prop_dictionary_t pkgd = NULL; - if (xbps_pkgdb_init(xhp) != 0) return NULL; - pkgd = xbps_find_pkg_in_array_by_pkgver(xhp, xhp->pkgdb, pkgver, NULL); - if (pkgd != NULL) - return prop_dictionary_copy(pkgd); - - return NULL; + return xbps_find_pkg_in_array_by_pkgver(xhp, xhp->pkgdb, pkgver, NULL); } bool diff --git a/lib/plist.c b/lib/plist.c index 115f546f..dbf59441 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -294,7 +294,6 @@ xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp, "pkgname", &savedpkgname); plistf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir, savedpkgname, plist); - prop_object_release(pkgd); if (plistf == NULL) return NULL; } diff --git a/lib/plist_find.c b/lib/plist_find.c index 67da698f..e333c744 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -342,7 +342,7 @@ find_pkgd_installed(struct xbps_handle *xhp, bool bypattern, bool virtual) { - prop_dictionary_t pkgd, rpkgd = NULL; + prop_dictionary_t pkgd = NULL; pkg_state_t state = 0; int rv; @@ -376,20 +376,20 @@ find_pkgd_installed(struct xbps_handle *xhp, return NULL; if (xbps_pkg_state_dictionary(pkgd, &state) != 0) - return rpkgd; + return NULL; switch (state) { case XBPS_PKG_STATE_INSTALLED: case XBPS_PKG_STATE_UNPACKED: - rpkgd = prop_dictionary_copy(pkgd); - break; + return pkgd; + /* NOTREACHED */ default: /* not fully installed */ errno = ENOENT; break; } - return rpkgd; + return NULL; } prop_dictionary_t diff --git a/lib/repository_finddeps.c b/lib/repository_finddeps.c index dfb4455c..01845e3e 100644 --- a/lib/repository_finddeps.c +++ b/lib/repository_finddeps.c @@ -245,11 +245,8 @@ find_repo_deps(struct xbps_handle *xhp, "pkgver", &pkgver_q); /* Check its state */ - rv = xbps_pkg_state_dictionary(tmpd, &state); - if (rv != 0) { - prop_object_release(tmpd); + if ((rv = xbps_pkg_state_dictionary(tmpd, &state)) != 0) break; - } if (xbps_match_virtual_pkg_in_dict(tmpd,reqpkg,true)) { /* * Check if required dependency is a virtual @@ -259,7 +256,6 @@ find_repo_deps(struct xbps_handle *xhp, xbps_dbg_printf_append(xhp, "[virtual] satisfied by " "`%s'.\n", pkgver_q); - prop_object_release(tmpd); continue; } rv = xbps_pkgpattern_match(pkgver_q, reqpkg); @@ -294,12 +290,10 @@ find_repo_deps(struct xbps_handle *xhp, xbps_dbg_printf_append(xhp, "installed " "`%s'.\n", pkgver_q); - prop_object_release(tmpd); continue; } } else { /* error matching pkgpattern */ - prop_object_release(tmpd); xbps_dbg_printf(xhp, "failed to match " "pattern %s with %s\n", reqpkg, pkgver_q); break; diff --git a/lib/repository_pool.c b/lib/repository_pool.c index 18bf4c6e..f5504b94 100644 --- a/lib/repository_pool.c +++ b/lib/repository_pool.c @@ -135,9 +135,11 @@ xbps_rpool_release(struct xbps_handle *xhp) for (i = 0; i < prop_array_count(xhp->repo_pool); i++) { d = prop_array_get(xhp->repo_pool, i); idx = prop_dictionary_get(d, "index"); - prop_dictionary_get_cstring_nocopy(d, "uri", &uri); - xbps_dbg_printf(xhp, "[rpool] unregistered repository '%s'\n", - uri); + if (xhp->flags & XBPS_FLAG_DEBUG) { + prop_dictionary_get_cstring_nocopy(d, "uri", &uri); + xbps_dbg_printf(xhp, "[rpool] unregistered " + "repository '%s'\n", uri); + } prop_object_release(idx); prop_object_release(d); } diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index 809b52c5..1662d3c8 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -121,7 +121,6 @@ transaction_find_pkg(struct xbps_handle *xhp, */ prop_dictionary_get_cstring_nocopy(pkg_pkgdb, "version", &instver); - prop_object_release(pkg_pkgdb); if (xbps_cmpver(repover, instver) <= 0) { xbps_dbg_printf(xhp, "[rpool] Skipping `%s-%s' " "(installed: %s-%s) from repository `%s'\n", @@ -279,11 +278,8 @@ xbps_transaction_install_pkg(struct xbps_handle *xhp, pkgd = xbps_pkgdb_get_pkgd(xhp, pkg, bypattern); if (pkgd) { - if (xbps_pkg_state_dictionary(pkgd, &state) != 0) { - prop_object_release(pkgd); + if (xbps_pkg_state_dictionary(pkgd, &state) != 0) return EINVAL; - } - prop_object_release(pkgd); if ((state == XBPS_PKG_STATE_INSTALLED) && !reinstall) { /* error out if pkg installed and no reinstall */ return EEXIST; @@ -315,7 +311,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp, * Prepare transaction dictionary and missing deps array. */ if ((rv = xbps_transaction_init(xhp)) != 0) - goto out; + return rv; unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps"); if (!recursive) @@ -324,19 +320,14 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp, * If recursive is set, find out which packages would be orphans * if the supplied package were already removed. */ - orphans_pkg = prop_array_create(); - if (orphans_pkg == NULL) { - rv = ENOMEM; - goto out; - } + if ((orphans_pkg = prop_array_create()) == NULL) + return ENOMEM; prop_array_set_cstring_nocopy(orphans_pkg, 0, pkgname); orphans = xbps_find_pkg_orphans(xhp, orphans_pkg); prop_object_release(orphans_pkg); - if (prop_object_type(orphans) != PROP_TYPE_ARRAY) { - rv = EINVAL; - goto out; - } + if (prop_object_type(orphans) != PROP_TYPE_ARRAY) + return EINVAL; count = prop_array_count(orphans); while (count--) { @@ -364,9 +355,6 @@ rmpkg: (prop_array_count(reqby) > 0)) rv = EEXIST; -out: - prop_object_release(pkgd); - return rv; } diff --git a/lib/transaction_package_replace.c b/lib/transaction_package_replace.c index b4ded352..8f36976a 100644 --- a/lib/transaction_package_replace.c +++ b/lib/transaction_package_replace.c @@ -95,7 +95,6 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) xbps_dbg_printf(xhp, "replaced and new package " "are equal (%s)\n", pkgname); - prop_object_release(instd); continue; } instd_reqby = prop_dictionary_get(instd, "requiredby"); @@ -181,7 +180,6 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) if (xbps_mkpath(dname, 0755) == -1) { if (errno != EEXIST) { free(buf); - prop_object_release(instd); prop_object_iterator_release(iter); return errno; } @@ -190,7 +188,6 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) free(buf); free(dirc); prop_object_release(filesd); - prop_object_release(instd); prop_object_iterator_release(iter); return errno; } @@ -205,7 +202,6 @@ xbps_transaction_package_replace(struct xbps_handle *xhp) prop_dictionary_set_cstring_nocopy(instd, "transaction", "remove"); if (!xbps_add_obj_to_array(transd_unsorted, instd)) { - prop_object_release(instd); prop_object_iterator_release(iter); return EINVAL; } diff --git a/lib/util.c b/lib/util.c index 070ef939..82e2ad9e 100644 --- a/lib/util.c +++ b/lib/util.c @@ -83,15 +83,10 @@ xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp, * Check that package state is fully installed, not * unpacked or something else. */ - if (xbps_pkg_state_dictionary(dict, &state) != 0) { - prop_object_release(dict); + if (xbps_pkg_state_dictionary(dict, &state) != 0) return -1; /* error */ - } - if (state != XBPS_PKG_STATE_INSTALLED) { - prop_object_release(dict); + if (state != XBPS_PKG_STATE_INSTALLED) return 0; /* not fully installed */ - } - prop_object_release(dict); return 1; } @@ -108,7 +103,6 @@ xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp, ((pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false)) == NULL)) return false; - prop_object_release(pkgd); return true; }