aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-store.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-store.c')
-rw-r--r--camel/camel-store.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/camel/camel-store.c b/camel/camel-store.c
index eedc9dfa2a..3c49f312ec 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -776,7 +776,7 @@ CamelFolderInfo *
camel_folder_info_build (GPtrArray *folders, const char *namespace,
char separator, gboolean short_names)
{
- CamelFolderInfo *fi, *pfi, *top = NULL;
+ CamelFolderInfo *fi, *pfi, *top = NULL, *tail = NULL;
GHashTable *hash;
char *name, *p, *pname;
int i, nlen;
@@ -854,9 +854,15 @@ camel_folder_info_build (GPtrArray *folders, const char *namespace,
g_hash_table_insert (hash, pname, pfi);
g_ptr_array_add (folders, pfi);
}
- fi->sibling = pfi->child;
+ tail = pfi->child;
+ if (tail == NULL) {
+ pfi->child = fi;
+ } else {
+ while (tail->sibling)
+ tail = tail->sibling;
+ tail->sibling = fi;
+ }
fi->parent = pfi;
- pfi->child = fi;
} else if (!top)
top = fi;
}
@@ -864,13 +870,18 @@ camel_folder_info_build (GPtrArray *folders, const char *namespace,
g_hash_table_destroy (hash);
/* Link together the top-level folders */
+ tail = top;
for (i = 0; i < folders->len; i++) {
fi = folders->pdata[i];
if (fi->parent || fi == top)
continue;
- if (top)
- fi->sibling = top;
- top = fi;
+ if (tail == NULL) {
+ tail = fi;
+ top = fi;
+ } else {
+ tail->sibling = fi;
+ tail = fi;
+ }
}
return top;