changeset 23455:d5c5512adc69

Fixed some leaks formatting
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Wed, 11 Jun 2008 03:51:47 +0000
parents 0ece981e44f5
children 8f397c8e728a
files libpurple/theme-manager.c
diffstat 1 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/theme-manager.c	Wed Jun 11 03:41:35 2008 +0000
+++ b/libpurple/theme-manager.c	Wed Jun 11 03:51:47 2008 +0000
@@ -111,7 +111,7 @@
                   		      gpointer value,
                 		      PTFunc user_data)
 {
-	if(PURPLE_IS_THEME(value))
+	if (PURPLE_IS_THEME(value))
 		(* user_data) (value);
 }
 
@@ -120,36 +120,38 @@
 {
 
 	GDir *rdir;
-	gchar *name, *type;
+	gchar *name, *type, *purple_dir, *theme_dir;
 	GDir *dir;
 	PurpleThemeLoader *loader;
 
-	rdir =  g_dir_open(root, 0, NULL);/*TODO: should have debug error?*/
+	rdir =  g_dir_open(root, 0, NULL);
 
 	g_return_if_fail(rdir);
 
-	/*TODO: This looks messy, leaks*/
 	/* Parses directory by root/name/purple/type */
-	while((name = g_strdup(g_dir_read_name (rdir)))){
-
-		dir =  g_dir_open(g_strconcat(root, '/', name,
-				  '/', "purple", NULL), 0, NULL);	
+	while ((name = g_strdup(g_dir_read_name (rdir)))){
+		
+		purple_dir = g_strconcat(root, '/', name, '/', "purple", NULL);
+		dir =  g_dir_open(purple_dir, 0, NULL);	
 	
-		if(dir) {
-			while((type = g_strdup(g_dir_read_name (dir)))) {
-				if((loader = g_hash_table_lookup (theme_table, type)))
-					purple_theme_manager_add_theme(purple_theme_loader_build(loader,  g_strconcat(root, '/', name, '/',
-												              "purple", '/', type, NULL)));
+		if (dir) {
+			while ((type = g_strdup(g_dir_read_name (dir)))) {
+				if ((loader = g_hash_table_lookup (theme_table, type))){
 
+					theme_dir = g_strconcat(purple_dir, '/', type, NULL);
+					purple_theme_manager_add_theme(purple_theme_loader_build(loader, theme_dir));
+
+				}
 				g_free(type);
+
 			}
-
 			g_dir_close(dir);
-		}
 
-		g_free(name);		
+		}
+		g_free(purple_dir);
+		g_free(name);	
+	
 	}
-
 	g_dir_close(rdir);
 	
 }
@@ -190,7 +192,7 @@
 	g_return_if_fail(type);
 
 	/* if something is already there do nothing */
-	if(! g_hash_table_lookup (theme_table, type)) 
+	if (! g_hash_table_lookup (theme_table, type)) 
 		g_hash_table_insert(theme_table, type, loader);
 	
 	g_free(type);
@@ -206,7 +208,7 @@
 	type = purple_theme_loader_get_type_string(loader);
 	g_return_if_fail(type);
 
-	if(g_hash_table_lookup (theme_table, type) == loader){
+	if (g_hash_table_lookup (theme_table, type) == loader){
 
 		g_hash_table_remove (theme_table, type);
 
@@ -243,7 +245,7 @@
 	g_return_if_fail(key);
 	
 	/* if something is already there do nothing */
-	if(! g_hash_table_lookup (theme_table, key)) 
+	if (! g_hash_table_lookup (theme_table, key)) 
 		g_hash_table_insert(theme_table, key, theme);
 	
 	g_free(key);