changeset 2267:2e961ce4bfe8

Fixes memory leaks that are visible during startup in scrobbler plugin (Bugzilla #26)
author Jussi Judin <jjudin+audacious@iki.fi>
date Tue, 25 Dec 2007 02:15:51 -0600
parents 5395c85a8724
children bcd96cdc3a92
files src/scrobbler/gerpok.c src/scrobbler/scrobbler.c
diffstat 2 files changed, 28 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/scrobbler/gerpok.c	Tue Dec 25 02:15:14 2007 -0600
+++ b/src/scrobbler/gerpok.c	Tue Dec 25 02:15:51 2007 -0600
@@ -745,10 +745,13 @@
 	char buf[PATH_MAX], *cache = NULL, *ptr1, *ptr2;
 	int cachesize, written, i = 0;
 	item_t *item;
+	gchar* config_datadir;
 
 	cachesize = written = 0;
 
-	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
+	config_datadir = audacious_get_localdir();
+	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", config_datadir);
+	g_free(config_datadir);
 
 	if (!(fd = fopen(buf, "r")))
 		return;
@@ -823,6 +826,7 @@
 	FILE *fd;
 	item_t *item;
 	char *home, buf[PATH_MAX];
+	gchar* config_datadir;
 
 	/*pdebug("Entering dump_queue();", DEBUG);*/
 
@@ -832,7 +836,9 @@
 		return;
 	}
 
-	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
+	config_datadir = audacious_get_localdir();
+	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", config_datadir);
+	g_free(config_datadir);
 
 	if (!(fd = fopen(buf, "w")))
 	{
--- a/src/scrobbler/scrobbler.c	Tue Dec 25 02:15:14 2007 -0600
+++ b/src/scrobbler/scrobbler.c	Tue Dec 25 02:15:51 2007 -0600
@@ -830,10 +830,13 @@
 	char buf[PATH_MAX], *cache = NULL, *ptr1, *ptr2;
 	int cachesize, written, i = 0;
 	item_t *item;
+	gchar* config_datadir;
 
 	cachesize = written = 0;
 
-	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
+	config_datadir = audacious_get_localdir();
+	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", config_datadir);
+	g_free(config_datadir);
 
 	if (!(fd = fopen(buf, "r")))
 		return;
@@ -884,10 +887,19 @@
 
 		{
 			Tuple *tuple = aud_tuple_new();
+			gchar* string_value;
 
-			aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, xmms_urldecode_plain(artist));
-			aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, xmms_urldecode_plain(title));
-			aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, xmms_urldecode_plain(album));
+			string_value = xmms_urldecode_plain(artist);
+			aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, string_value);
+			g_free(string_value);
+
+			string_value = xmms_urldecode_plain(title);
+			aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, string_value);
+			g_free(string_value);
+
+			string_value = xmms_urldecode_plain(album);
+			aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, string_value);
+			g_free(string_value);
 
 			item = q_put(tuple, atoi(len));
 
@@ -919,6 +931,7 @@
 	FILE *fd;
 	item_t *item;
 	char *home, buf[PATH_MAX];
+	gchar* config_datadir;
 
 	/*pdebug("Entering dump_queue();", DEBUG);*/
 
@@ -928,7 +941,9 @@
 		return;
 	}
 
-	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
+	config_datadir = audacious_get_localdir();
+	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", config_datadir);
+	g_free(config_datadir);
 
 	if (!(fd = fopen(buf, "w")))
 	{