[gnome-software] Use GString with g_autoptr
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use GString with g_autoptr
- Date: Thu, 10 Sep 2015 21:04:57 +0000 (UTC)
commit 38e03971c8a43eb2b98b2bacfbcb18457f7fc0e3
Author: Kalev Lember <klember redhat com>
Date: Thu Sep 10 22:39:23 2015 +0200
Use GString with g_autoptr
... and bump glib dep to 2.45.8 for g_autoptr(GString) support.
configure.ac | 2 +-
src/gs-app-addon-row.c | 3 +--
src/gs-cleanup.h | 10 ----------
src/gs-feature-tile.c | 3 +--
src/gs-offline-updates.c | 3 +--
src/gs-page.c | 3 +--
src/gs-plugin-loader.c | 5 ++---
src/gs-shell-extras.c | 2 +-
src/gs-utils.c | 5 ++---
src/plugins/gs-plugin-fedora-tagger-ratings.c | 3 +--
10 files changed, 11 insertions(+), 28 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b44a96f..927cba0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,7 @@ GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE(GETTEXT_PACKAGE, "AC_PACKAGE_NAME", [gnome-software])
-AM_PATH_GLIB_2_0(2.44.0, :, AC_MSG_ERROR([GLib is required]), gobject gmodule gio)
+AM_PATH_GLIB_2_0(2.45.8, :, AC_MSG_ERROR([GLib is required]), gobject gmodule gio)
AM_GLIB_GNU_GETTEXT
GLIB_GSETTINGS
diff --git a/src/gs-app-addon-row.c b/src/gs-app-addon-row.c
index e7d2dba..bce2167 100644
--- a/src/gs-app-addon-row.c
+++ b/src/gs-app-addon-row.c
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include "gs-app-addon-row.h"
-#include "gs-cleanup.h"
#include "gs-utils.h"
struct _GsAppAddonRow
@@ -73,7 +72,7 @@ gs_app_addon_row_get_summary (GsAppAddonRow *row)
void
gs_app_addon_row_refresh (GsAppAddonRow *row)
{
- _cleanup_string_free_ GString *str = NULL;
+ g_autoptr(GString) str = NULL;
if (row->app == NULL)
return;
diff --git a/src/gs-cleanup.h b/src/gs-cleanup.h
index 94dac41..a4785c2 100644
--- a/src/gs-cleanup.h
+++ b/src/gs-cleanup.h
@@ -33,19 +33,9 @@ G_BEGIN_DECLS
func (*(Type*)v); \
}
-#define GS_DEFINE_CLEANUP_FUNCTIONt(Type, name, func) \
- static inline void name (void *v) \
- { \
- if (*(Type*)v) \
- func (*(Type*)v, TRUE); \
- }
-
-GS_DEFINE_CLEANUP_FUNCTIONt(GString*, gs_local_free_string, g_string_free)
-
GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_plugin_list, gs_plugin_list_free)
#define _cleanup_plugin_list_free_ __attribute__ ((cleanup(gs_local_free_plugin_list)))
-#define _cleanup_string_free_ __attribute__ ((cleanup(gs_local_free_string)))
G_END_DECLS
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index 9d84f92..a37f759 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -24,7 +24,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include "gs-cleanup.h"
#include "gs-feature-tile.h"
struct _GsFeatureTile
@@ -95,7 +94,7 @@ gs_feature_tile_set_app (GsFeatureTile *tile, GsApp *app)
const gchar *stroke_color;
const gchar *text_color;
const gchar *text_shadow;
- _cleanup_string_free_ GString *data = NULL;
+ g_autoptr(GString) data = NULL;
g_return_if_fail (GS_IS_FEATURE_TILE (tile));
g_return_if_fail (GS_IS_APP (app) || app == NULL);
diff --git a/src/gs-offline-updates.c b/src/gs-offline-updates.c
index 92b0302..5fbdab4 100644
--- a/src/gs-offline-updates.c
+++ b/src/gs-offline-updates.c
@@ -25,7 +25,6 @@
#include <packagekit-glib2/packagekit.h>
#include <polkit/polkit.h>
-#include "gs-cleanup.h"
#include "gs-offline-updates.h"
#include "gs-utils.h"
@@ -198,7 +197,7 @@ insert_details_widget (GtkMessageDialog *dialog, const gchar *details)
GtkWidget *box, *tv;
GtkTextBuffer *buffer;
GList *children;
- _cleanup_string_free_ GString *msg = NULL;
+ g_autoptr(GString) msg = NULL;
if (!details)
return;
diff --git a/src/gs-page.c b/src/gs-page.c
index 602ce5d..b6fdddc 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -26,7 +26,6 @@
#include "gs-app.h"
#include "gs-app-row.h"
-#include "gs-cleanup.h"
#include "gs-page.h"
#include "gs-shell.h"
#include "gs-utils.h"
@@ -155,7 +154,7 @@ gs_page_remove_app (GsPage *page, GsApp *app)
GsPagePrivate *priv = gs_page_get_instance_private (page);
GtkResponseType response;
GtkWidget *dialog;
- _cleanup_string_free_ GString *markup = NULL;
+ g_autoptr(GString) markup = NULL;
markup = g_string_new ("");
g_string_append_printf (markup,
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 62dc13e..f494f5a 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -24,7 +24,6 @@
#include <glib/gi18n.h>
#include <appstream-glib.h>
-#include "gs-cleanup.h"
#include "gs-plugin-loader.h"
#include "gs-plugin.h"
#include "gs-profile.h"
@@ -1355,7 +1354,7 @@ gs_plugin_loader_convert_unavailable_app (GsApp *app, const gchar *search)
GPtrArray *keywords;
const gchar *keyword;
guint i;
- _cleanup_string_free_ GString *tmp = NULL;
+ g_autoptr(GString) tmp = NULL;
/* is the search string one of the codec keywords */
keywords = gs_app_get_keywords (app);
@@ -2449,7 +2448,7 @@ save_install_queue (GsPluginLoader *plugin_loader)
gboolean ret;
gint i;
g_autoptr(GError) error = NULL;
- _cleanup_string_free_ GString *s = NULL;
+ g_autoptr(GString) s = NULL;
g_autofree gchar *file = NULL;
s = g_string_new ("");
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index 71167fc..29dc71c 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -1060,7 +1060,7 @@ row_activated_cb (GtkListBox *list_box,
static gchar *
get_app_sort_key (GsApp *app)
{
- _cleanup_string_free_ GString *key = NULL;
+ g_autoptr(GString) key = NULL;
key = g_string_sized_new (64);
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 4a6dfac..bc3538e 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include "gs-app.h"
-#include "gs-cleanup.h"
#include "gs-utils.h"
#include "gs-plugin.h"
@@ -218,8 +217,8 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent)
};
g_autofree gchar *origin_url = NULL;
g_autoptr(GSettings) settings = NULL;
- _cleanup_string_free_ GString *body = NULL;
- _cleanup_string_free_ GString *title = NULL;
+ g_autoptr(GString) body = NULL;
+ g_autoptr(GString) title = NULL;
/* this is very crude */
licence = gs_app_get_licence (app);
diff --git a/src/plugins/gs-plugin-fedora-tagger-ratings.c b/src/plugins/gs-plugin-fedora-tagger-ratings.c
index 9c9dff8..8906b4d 100644
--- a/src/plugins/gs-plugin-fedora-tagger-ratings.c
+++ b/src/plugins/gs-plugin-fedora-tagger-ratings.c
@@ -26,7 +26,6 @@
#include <sqlite3.h>
#include <stdlib.h>
-#include "gs-cleanup.h"
#include <gs-plugin.h>
#include <gs-utils.h>
@@ -114,7 +113,7 @@ gs_plugin_parse_json (const gchar *data, gsize data_len, const gchar *key)
guint i;
gchar *tmp;
guint len;
- _cleanup_string_free_ GString *string = NULL;
+ g_autoptr(GString) string = NULL;
g_auto(GStrv) split = NULL;
/* format the key to match what JSON returns */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]