From 3087186a36af2ccf37bc594aa24ef55de9b3e232 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 17 Dec 2015 21:07:52 +0100 Subject: [PATCH] lib: Make list_remotes return a GPtrArray --- lib/test-lib.c | 25 +++++++++++++------------ lib/xdg-app-installation.c | 7 +++---- lib/xdg-app-installation.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/test-lib.c b/lib/test-lib.c index f29deab7..72757f98 100644 --- a/lib/test-lib.c +++ b/lib/test-lib.c @@ -21,7 +21,7 @@ main (int argc, char *argv[]) XdgAppInstalledRef *app1; XdgAppInstalledRef *app2; XdgAppRemoteRef *remote_ref; - XdgAppRemote **remotes; + g_autoptr(GPtrArray) remotes = NULL; GError *error = NULL; int i, j; @@ -178,18 +178,19 @@ main (int argc, char *argv[]) remotes = xdg_app_installation_list_remotes (installation, NULL, NULL); - for (i = 0; remotes[i] != NULL; i++) + for (i = 0; i < remotes->len; i++) { + XdgAppRemote *remote = g_ptr_array_index(remotes, i); g_autoptr(GPtrArray) refs = NULL; g_print ("\nRemote: %s %s %s %d %d\n", - xdg_app_remote_get_name (remotes[i]), - xdg_app_remote_get_url (remotes[i]), - xdg_app_remote_get_title (remotes[i]), - xdg_app_remote_get_gpg_verify (remotes[i]), - xdg_app_remote_get_noenumerate (remotes[i])); + xdg_app_remote_get_name (remote), + xdg_app_remote_get_url (remote), + xdg_app_remote_get_title (remote), + xdg_app_remote_get_gpg_verify (remote), + xdg_app_remote_get_noenumerate (remote)); - g_print ("\n**** Listing remote refs on %s\n", xdg_app_remote_get_name (remotes[i])); - refs = xdg_app_installation_list_remote_refs_sync (installation, xdg_app_remote_get_name (remotes[i]), + g_print ("\n**** Listing remote refs on %s\n", xdg_app_remote_get_name (remote)); + refs = xdg_app_installation_list_remote_refs_sync (installation, xdg_app_remote_get_name (remote), NULL, NULL); if (refs) { @@ -206,9 +207,9 @@ main (int argc, char *argv[]) } } - g_print ("\n**** Getting remote gedit master on %s\n", xdg_app_remote_get_name (remotes[i])); + g_print ("\n**** Getting remote gedit master on %s\n", xdg_app_remote_get_name (remote)); error = NULL; - remote_ref = xdg_app_installation_fetch_remote_ref_sync (installation, xdg_app_remote_get_name (remotes[i]), + remote_ref = xdg_app_installation_fetch_remote_ref_sync (installation, xdg_app_remote_get_name (remote), XDG_APP_REF_KIND_APP, "org.gnome.gedit", NULL, "master", NULL, &error); @@ -224,7 +225,7 @@ main (int argc, char *argv[]) xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)), xdg_app_remote_ref_get_remote_name (remote_ref)); - metadata = xdg_app_installation_fetch_remote_metadata_sync (installation, xdg_app_remote_get_name (remotes[i]), + metadata = xdg_app_installation_fetch_remote_metadata_sync (installation, xdg_app_remote_get_name (remote), xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)), NULL, &error); if (metadata) { diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index 31343892..bb85cfa1 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -397,10 +397,10 @@ xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self, * * Lists the remotes. * - * Returns: (transfer full) (array zero-terminated=1): an array of + * Returns: (transfer container) (element-type XdgAppRemote): an GPtrArray of * #XdgAppRemote instances */ -XdgAppRemote ** +GPtrArray * xdg_app_installation_list_remotes (XdgAppInstallation *self, GCancellable *cancellable, GError **error) @@ -418,8 +418,7 @@ xdg_app_installation_list_remotes (XdgAppInstallation *self, g_ptr_array_add (remotes, xdg_app_remote_new (priv->dir, remote_names[i])); - g_ptr_array_add (remotes, NULL); - return (XdgAppRemote **)g_ptr_array_free (g_steal_pointer (&remotes), FALSE); + return g_steal_pointer (&remotes); } char * diff --git a/lib/xdg-app-installation.h b/lib/xdg-app-installation.h index 339fa5fb..e3e5247b 100644 --- a/lib/xdg-app-installation.h +++ b/lib/xdg-app-installation.h @@ -86,7 +86,7 @@ XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_current_installed_a const char *name, GCancellable *cancellable, GError **error); -XDG_APP_EXTERN XdgAppRemote ** xdg_app_installation_list_remotes (XdgAppInstallation *self, +XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_remotes (XdgAppInstallation *self, GCancellable *cancellable, GError **error); XDG_APP_EXTERN char * xdg_app_installation_load_app_overrides (XdgAppInstallation *self,