From 90e62f364e5bad38b741ba0df38a7555f6d2045c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 11 Jul 2017 11:07:59 +0200 Subject: thumbnail: Simplify init_thumbnailers_dirs() origin commit: https://gitlab.gnome.org/GNOME/gnome-desktop/commit/a0702a2 --- libmate-desktop/mate-desktop-thumbnail.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libmate-desktop/mate-desktop-thumbnail.c') diff --git a/libmate-desktop/mate-desktop-thumbnail.c b/libmate-desktop/mate-desktop-thumbnail.c index 3a14a68..e88c537 100644 --- a/libmate-desktop/mate-desktop-thumbnail.c +++ b/libmate-desktop/mate-desktop-thumbnail.c @@ -220,19 +220,18 @@ static gpointer init_thumbnailers_dirs (gpointer data) { const gchar * const *data_dirs; - gchar **thumbs_dirs; - guint i, length; + GPtrArray *thumbs_dirs; + guint i; data_dirs = g_get_system_data_dirs (); - length = g_strv_length ((char **) data_dirs); + thumbs_dirs = g_ptr_array_new (); - thumbs_dirs = g_new (gchar *, length + 2); - thumbs_dirs[0] = g_build_filename (g_get_user_data_dir (), "thumbnailers", NULL); - for (i = 0; i < length; i++) - thumbs_dirs[i + 1] = g_build_filename (data_dirs[i], "thumbnailers", NULL); - thumbs_dirs[length + 1] = NULL; + g_ptr_array_add (thumbs_dirs, g_build_filename (g_get_user_data_dir (), "thumbnailers", NULL)); + for (i = 0; data_dirs[i] != NULL; i++) + g_ptr_array_add (thumbs_dirs, g_build_filename (data_dirs[i], "thumbnailers", NULL)); + g_ptr_array_add (thumbs_dirs, NULL); - return thumbs_dirs; + return g_ptr_array_free (thumbs_dirs, FALSE); } static const gchar * const * -- cgit v1.2.1