[telegnome] Use more modern memory-freeing functions.
- From: Colin Watson <cjwatson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [telegnome] Use more modern memory-freeing functions.
- Date: Fri, 1 Feb 2013 01:01:06 +0000 (UTC)
commit 98982c8322b934a6c0942ed63fcc97454806e736
Author: Colin Watson <cjwatson debian org>
Date: Fri Feb 1 01:00:27 2013 +0000
Use more modern memory-freeing functions.
* src/gui.c (load_channels_from_config, cb_quit): Use
g_slist_free_full.
* src/pixpack.c (pixpack_destroy): Use g_clear_object and
g_clear_pointer.
* src/prefs.c (prefs_cancel_cb): Likewise.
* src/view.c (tele_view_free): Use g_clear_object.
* configure.ac (PKG_CHECK_MODULES): Require glib-2.0 >= 2.34 for
g_clear_pointer.
ChangeLog | 13 +++++++++++++
configure.ac | 2 +-
src/gui.c | 14 ++------------
src/pixpack.c | 7 +++----
src/prefs.c | 5 ++---
src/view.c | 3 +--
6 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 92fd21c..1e5b71a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-02-01 Colin Watson <cjwatson debian org>
+
+ Use more modern memory-freeing functions.
+
+ * src/gui.c (load_channels_from_config, cb_quit): Use
+ g_slist_free_full.
+ * src/pixpack.c (pixpack_destroy): Use g_clear_object and
+ g_clear_pointer.
+ * src/prefs.c (prefs_cancel_cb): Likewise.
+ * src/view.c (tele_view_free): Use g_clear_object.
+ * configure.ac (PKG_CHECK_MODULES): Require glib-2.0 >= 2.34 for
+ g_clear_pointer.
+
2010-11-03 Colin Watson <cjwatson debian org>
Port from GnomeVFS to GIO.
diff --git a/configure.ac b/configure.ac
index 2965210..4d3b71f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@ AC_PROG_CPP
AC_HEADER_STDC
AC_PROG_INSTALL
-PKG_CHECK_MODULES([TELEGNOME], [glib-2.0 gtk+-2.0 >= 2.20 gdk-pixbuf-2.0 libgnomeui-2.0 gio-2.0])
+PKG_CHECK_MODULES([TELEGNOME], [glib-2.0 >= 2.34 gtk+-2.0 >= 2.20 gdk-pixbuf-2.0 libgnomeui-2.0 gio-2.0])
PROGRAMS_TELEGNOME="telegnome"
AC_SUBST(PROGRAMS_TELEGNOME)
diff --git a/src/gui.c b/src/gui.c
index 0f332ab..81316d9 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -331,12 +331,7 @@ load_channels_from_config()
Channel *channel;
if (gui.channels != NULL) {
- GSList *old_channels = gui.channels;
- while (old_channels != NULL) {
- channel_free((Channel *)old_channels->data);
- old_channels = g_slist_next(old_channels);
- }
- g_slist_free(gui.channels);
+ g_slist_free_full(gui.channels, channel_free);
gui.channels = NULL;
}
@@ -511,12 +506,7 @@ cb_quit (GtkWidget* widget, gpointer data)
/* free the channels */
if (gui.channels != NULL) {
- GSList *old_channels = gui.channels;
- while (old_channels != NULL) {
- channel_free((Channel *)old_channels->data);
- old_channels = g_slist_next(old_channels);
- }
- g_slist_free(gui.channels);
+ g_slist_free_full(gui.channels, channel_free);
gui.channels = NULL;
}
tele_view_free(currentview);
diff --git a/src/pixpack.c b/src/pixpack.c
index 24da76d..bea558f 100644
--- a/src/pixpack.c
+++ b/src/pixpack.c
@@ -131,12 +131,11 @@ pixpack_destroy(GtkObject *object)
if (private) {
if (private->pixbuf)
- g_object_unref(private->pixbuf);
+ g_clear_object(&private->pixbuf);
if (private->scaled_pixbuf)
- g_object_unref(private->scaled_pixbuf);
+ g_clear_object(&private->scaled_pixbuf);
- g_free(pixpack->private_data);
- pixpack->private_data = NULL;
+ g_clear_pointer(&pixpack->private_data, g_free);
}
if (GTK_OBJECT_CLASS(parent_class)->destroy)
diff --git a/src/prefs.c b/src/prefs.c
index a758a2a..0c7e54f 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -391,9 +391,8 @@ prefs_channel_move_down_cb(void)
void
prefs_cancel_cb(void)
{
- g_object_unref(prefs_window->box);
- g_free(prefs_window);
- prefs_window = NULL;
+ g_clear_object(&prefs_window->box);
+ g_clear_pointer(&prefs_window, g_free);
}
void
diff --git a/src/view.c b/src/view.c
index adbf8a8..8bb40cd 100644
--- a/src/view.c
+++ b/src/view.c
@@ -154,8 +154,7 @@ void
tele_view_free(TeleView *view)
{
/* clean up */
- g_object_unref(view->box);
- view->box = NULL;
+ g_clear_object(&view->box);
g_free(view);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]