From f464fc13b1ce4c96807628f54a752a719d64ac66 Mon Sep 17 00:00:00 2001 From: Monsta Date: Thu, 20 Nov 2014 13:19:15 +0300 Subject: clock: Use lists instead of arrays Closes https://github.com/mate-desktop/mate-panel/pull/258 --- applets/clock/clock.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'applets/clock') diff --git a/applets/clock/clock.c b/applets/clock/clock.c index efaba2fd..56a991ea 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -2483,28 +2483,16 @@ loc_to_string (ClockLocation *loc) static void save_cities_store (ClockData *cd) { - ClockLocation *loc; - GList *node = cd->locations; - gint len = g_list_length(cd->locations); - gchar **array[len + 1]; - gchar **array_reverse[len + 1]; - gint i = 0; - - while (node) { - loc = CLOCK_LOCATION (node->data); - array[i] = loc_to_string (loc); - i++; - node = node->next; - } - array[i] = NULL; + GList *locs = NULL; + GList *node; - for (i = 0; i <= (len - 1); i++) { - array_reverse [len - i - 1] = g_strdup (array [i]); + for (node = cd->locations; node != NULL; node = node->next) { + locs = g_list_prepend (locs, loc_to_string (CLOCK_LOCATION (node->data))); } - array_reverse[i] = NULL; - g_settings_set_strv (cd->settings, KEY_CITIES, (const gchar **) array_reverse); - /* FIXME free arrays */ + locs = g_list_reverse (locs); + mate_panel_applet_settings_set_glist (cd->settings, KEY_CITIES, locs); + g_list_free_full (locs, g_free); } static void -- cgit v1.2.1