[gtksourceview] Free return value of gtk_source_completion_model_get_providers()



commit 2f380e91ba63d3446b1c4f6a2f261db91cb6c5f8
Author: SÃbastien Wilmet <swilmet gnome org>
Date:   Mon Jan 14 19:11:50 2013 +0100

    Free return value of gtk_source_completion_model_get_providers()
    
    In select_provider(), the variable 'providers' was declared a second
    time, that's why it's renamed to 'visible_providers'.

 gtksourceview/gtksourcecompletion.c |   13 +++++++++----
 tests/test-completion-model.c       |    1 +
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 28d1d7d..be58f14 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -675,6 +675,8 @@ get_num_visible_providers (GtkSourceCompletion *completion,
 			}
 		}
 	}
+
+	g_list_free (providers);
 }
 
 static void
@@ -778,7 +780,6 @@ select_provider (GtkSourceCompletion *completion,
 	GtkSourceCompletionProvider *visible;
 	guint i;
 
-	providers = gtk_source_completion_model_get_providers (completion->priv->model_proposals);
 	visible = get_visible_provider (completion);
 
 	get_num_visible_providers (completion, &num, &pos);
@@ -798,6 +799,8 @@ select_provider (GtkSourceCompletion *completion,
 		return FALSE;
 	}
 
+	providers = gtk_source_completion_model_get_providers (completion->priv->model_proposals);
+
 	if (visible != NULL)
 	{
 		orig = g_list_find (providers, visible);
@@ -848,16 +851,17 @@ select_provider (GtkSourceCompletion *completion,
 
 	if (orig == current)
 	{
+		g_list_free (providers);
 		return FALSE;
 	}
 
 	if (current != NULL)
 	{
-		GList *providers = g_list_append (NULL, current->data);
+		GList *visible_providers = g_list_append (NULL, current->data);
 
 		gtk_source_completion_model_set_visible_providers (completion->priv->model_proposals,
-		                                                   providers);
-		g_list_free (providers);
+		                                                   visible_providers);
+		g_list_free (visible_providers);
 		visible_provider_changed (completion);
 	}
 	else
@@ -867,6 +871,7 @@ select_provider (GtkSourceCompletion *completion,
 		visible_provider_changed (completion);
 	}
 
+	g_list_free (providers);
 	return TRUE;
 }
 
diff --git a/tests/test-completion-model.c b/tests/test-completion-model.c
index b71b335..198df5c 100644
--- a/tests/test-completion-model.c
+++ b/tests/test-completion-model.c
@@ -626,6 +626,7 @@ test_get_providers (void)
 
 	g_object_unref (model);
 	free_providers (all_providers, all_list_proposals);
+	g_list_free (providers_get);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]