tree-wide: Use autoptr cleanup for HyQuery

This was a noticeable source of leaks.

Closes: #644
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-02-24 09:09:46 -05:00 committed by Atomic Bot
parent c0b4fbc0f5
commit cc20f32fb7
4 changed files with 10 additions and 20 deletions

View File

@ -718,7 +718,7 @@ find_pkgs_in_rpmdb (int rootfs_dfd, GHashTable *pkgs,
while (g_hash_table_iter_next (&it, &itkey, NULL))
{
g_autoptr(GPtrArray) pkglist = NULL;
HyQuery query = hy_query_create (rsack->sack);
hy_autoquery HyQuery query = hy_query_create (rsack->sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
hy_query_filter (query, HY_PKG_NAME, HY_EQ, itkey);
pkglist = hy_query_run (query);
@ -1173,7 +1173,7 @@ add_package_refs_to_set (RpmOstreeRefSack *rsack,
GError **error)
{
g_autoptr(GPtrArray) pkglist = NULL;
HyQuery query = hy_query_create (rsack->sack);
hy_autoquery HyQuery query = hy_query_create (rsack->sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
pkglist = hy_query_run (query);

View File

@ -39,7 +39,7 @@
static GPtrArray *
query_all_packages_in_sack (RpmOstreeRefSack *rsack)
{
HyQuery hquery = NULL;
hy_autoquery HyQuery hquery = NULL;
g_autoptr(GPtrArray) pkglist = NULL;
GPtrArray *result;
int i, c;
@ -57,8 +57,6 @@ query_all_packages_in_sack (RpmOstreeRefSack *rsack)
g_ptr_array_add (result, _rpm_ostree_package_new (rsack, pkg));
}
if (hquery)
hy_query_free (hquery);
return g_steal_pointer (&result);
}
@ -141,26 +139,24 @@ rpm_ostree_db_diff (OstreeRepo *repo,
if (!orig_sack)
goto out;
{ HyQuery query = hy_query_create (orig_sack->sack);
{ hy_autoquery HyQuery query = hy_query_create (orig_sack->sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
orig_pkglist = hy_query_run (query);
hy_query_free (query);
}
new_sack = rpmostree_get_refsack_for_commit (repo, new_ref, cancellable, error);
if (!new_sack)
goto out;
{ HyQuery query = hy_query_create (new_sack->sack);
{ hy_autoquery HyQuery query = hy_query_create (new_sack->sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
new_pkglist = hy_query_run (query);
hy_query_free (query);
}
for (i = 0; i < new_pkglist->len; i++)
{
DnfPackage *pkg = new_pkglist->pdata[i];
HyQuery query = NULL;
hy_autoquery HyQuery query = NULL;
g_autoptr(GPtrArray) pkglist = NULL;
guint count;
DnfPackage *oldpkg;
@ -185,7 +181,7 @@ rpm_ostree_db_diff (OstreeRepo *repo,
for (i = 0; i < orig_pkglist->len; i++)
{
DnfPackage *pkg = orig_pkglist->pdata[i];
HyQuery query = NULL;
hy_autoquery HyQuery query = NULL;
g_autoptr(GPtrArray) pkglist = NULL;
query = hy_query_create (new_sack->sack);
@ -195,13 +191,12 @@ rpm_ostree_db_diff (OstreeRepo *repo,
if (pkglist->len == 0)
g_ptr_array_add (ret_removed, _rpm_ostree_package_new (orig_sack, pkg));
hy_query_free (query);
}
for (i = 0; i < new_pkglist->len; i++)
{
DnfPackage *pkg = new_pkglist->pdata[i];
HyQuery query = NULL;
hy_autoquery HyQuery query = NULL;
g_autoptr(GPtrArray) pkglist = NULL;
query = hy_query_create (orig_sack->sack);
@ -211,7 +206,6 @@ rpm_ostree_db_diff (OstreeRepo *repo,
if (pkglist->len == 0)
g_ptr_array_add (ret_added, _rpm_ostree_package_new (new_sack, pkg));
hy_query_free (query);
}
ret = TRUE;

View File

@ -939,7 +939,7 @@ handle_remove_files_from_package (int rootfs_fd,
const char *pkgname = json_array_get_string_element (removespec, 0);
guint i, j, npackages;
guint len = json_array_get_length (removespec);
HyQuery query = NULL;
hy_autoquery HyQuery query = NULL;
g_autoptr(GPtrArray) pkglist = NULL;
query = hy_query_create (refsack->sack);
@ -991,8 +991,6 @@ handle_remove_files_from_package (int rootfs_fd,
ret = TRUE;
out:
if (query)
hy_query_free (query);
return ret;
}

View File

@ -930,7 +930,7 @@ rpmostree_get_pkglist_for_root (int dfd,
{
gboolean ret = FALSE;
g_autoptr(RpmOstreeRefSack) refsack = NULL;
HyQuery query = NULL;
hy_autoquery HyQuery query = NULL;
g_autoptr(GPtrArray) pkglist = NULL;
refsack = rpmostree_get_refsack_for_root (dfd, path, cancellable, error);
@ -947,8 +947,6 @@ rpmostree_get_pkglist_for_root (int dfd,
if (out_pkglist)
*out_pkglist = g_steal_pointer (&pkglist);
out:
if (query)
hy_query_free (query);
return ret;
}