[gnome-commander/get_rid_of_xml] Calculate the lenght of GList only once in set_gsettings_string_array_from_glist
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/get_rid_of_xml] Calculate the lenght of GList only once in set_gsettings_string_array_from_glist
- Date: Thu, 22 Nov 2018 07:36:34 +0000 (UTC)
commit 9bc398c23ee15ffc93f54f1b9fa05b282d71f3ce
Author: Uwe Scholz <u scholz83 gmx de>
Date: Tue Nov 20 14:10:14 2018 +0100
Calculate the lenght of GList only once in set_gsettings_string_array_from_glist
src/gnome-cmd-data.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 78b26847..70c58c13 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -2529,8 +2529,9 @@ gboolean GnomeCmdData::set_gsettings_string_array_from_glist (GSettings *setting
else
{
guint ii;
+ guint numberOfStrings = g_list_length (strings);
gchar** str_array;
- str_array = (gchar**) g_malloc ((g_list_length (strings) + 1) * sizeof(char*));
+ str_array = (gchar**) g_malloc ((numberOfStrings + 1) * sizeof(char*));
// Build up a NULL terminated char array for storage in GSettings
for (ii = 0; strings; strings = strings->next, ++ii)
@@ -2542,7 +2543,7 @@ gboolean GnomeCmdData::set_gsettings_string_array_from_glist (GSettings *setting
rv = g_settings_set_strv(settings_given, key, str_array);
// Free the char array
- for (ii = 0; ii < (g_list_length (strings) + 1); ii++)
+ for (ii = 0; ii < (numberOfStrings + 1); ii++)
{
g_free(str_array[ii]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]