summaryrefslogtreecommitdiff
path: root/xfdesktop/xfdesktop-4.10.3-backdrop-change-fix.patch
blob: 068bde753bd2b9f3c9fd93dda82b41ebefd50735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff -ur xfdesktop-4.10.3.org/common/xfdesktop-common.c xfdesktop-4.10.3/common/xfdesktop-common.c
--- xfdesktop-4.10.3.org/common/xfdesktop-common.c	2014-11-16 07:20:57.000000000 +0100
+++ xfdesktop-4.10.3/common/xfdesktop-common.c	2014-12-11 08:58:23.511865532 +0100
@@ -102,26 +102,38 @@
     items = 0;
     files = g_strsplit(contents, "\n", -1);
 
+    g_free(contents); /* not needed anymore */
+
     /* Since the first line is the file identifier, we need to skip it.
      * Additionally, we want to skip blank lines. */
-    for(i = 1; files[i] != NULL; i++) {
-        if(g_strcmp0(files[i], "") != 0) {
-            g_free(files[items]);
-            files[items] = g_strdup(files[i]);
-            DBG("files[items] %s", files[items]);
-            items++;
+
+     /* a file with just the header will have only one line */
+
+    if(files[0] != NULL)
+    {
+        g_free(files[0]);   /* that's the only non-empty line we need to remove */
+        files[0] = NULL;
+        for(i = 1; files[i] != NULL; i++) {
+            if(g_strcmp0(files[i], "") != 0) {
+                files[items]=files[i];  /* move the string to the current item slot */
+
+                items++;
+            } else { 
+                g_free(files[i]);   /* free the irrelevant empty string */
+            }
         }
+        files[items] = NULL; /* set the sentinel */
+
+        /* resize */
+        
+        files = g_realloc(files, sizeof(gchar *) * (items+1));
     }
-    files[items+1] = NULL;
 
-    files = g_realloc(files, sizeof(gchar *) * (items+1));
 
     DBG("items %d", items);
     if(n_items)
         *n_items = items;
 
-    g_free(contents);
-
     return files;
 }
 
bgstack15