static GHashTable *procmsg_read_mark_file (const gchar *folder);
void procmsg_msginfo_write_flags (MsgInfo *msginfo);
-static void procmsg_update_unread_children (MsgInfo *info, gboolean newly_marked);
GHashTable *procmsg_msg_hash_table_create(GSList *mlist)
{
if (msginfo->refcnt > 0)
return;
+ debug_print("freeing msginfo %d is %s\n", msginfo->msgnum, msginfo->folder ? msginfo->folder->path : "(nil)");
+
if (msginfo->to_folder) {
msginfo->to_folder->op_count--;
folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
-GSList *procmsg_find_children (MsgInfo *info)
+GSList *procmsg_find_children_func(MsgInfo *info,
+ GSList *children, GSList *all)
{
- GSList *children = NULL;
- GSList *all, *cur;
-
- g_return_val_if_fail(info!=NULL, NULL);
+ GSList *cur;
+
+ g_return_val_if_fail(info!=NULL, children);
if (info->msgid == NULL)
- return NULL;
- all = folder_item_get_msg_list(info->folder);
+ return children;
+
for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
MsgInfo *tmp = (MsgInfo *)cur->data;
if (tmp->inreplyto && !strcmp(tmp->inreplyto, info->msgid)) {
- GSList *grand_children;
- children = g_slist_prepend(children, tmp);
- grand_children = procmsg_find_children(tmp);
- children = slist_concat_unique(children, grand_children);
- g_slist_free(grand_children);
+ /* Check if message is already in the list */
+ if ((children == NULL) ||
+ (g_slist_index(children, tmp) == -1)) {
+ children = g_slist_prepend(children,
+ procmsg_msginfo_new_ref(tmp));
+ children = procmsg_find_children_func(tmp,
+ children,
+ all);
+ }
}
- if (tmp && tmp != info)
- procmsg_msginfo_free(tmp);
}
-
return children;
}
-static void procmsg_update_unread_children(MsgInfo *info, gboolean newly_marked)
+GSList *procmsg_find_children (MsgInfo *info)
+{
+ GSList *children;
+ GSList *all, *cur;
+
+ g_return_val_if_fail(info!=NULL, NULL);
+ all = folder_item_get_msg_list(info->folder);
+ children = procmsg_find_children_func(info, NULL, all);
+ if (children != NULL) {
+ for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
+ /* this will not free the used pointers
+ created with procmsg_msginfo_new_ref */
+ procmsg_msginfo_free((MsgInfo *)cur->data);
+ }
+ }
+ g_slist_free(all);
+
+ return children;
+}
+
+void procmsg_update_unread_children(MsgInfo *info, gboolean newly_marked)
{
GSList *children = procmsg_find_children(info);
GSList *cur;
}
procmsg_msginfo_free(tmp);
}
+ g_slist_free(children);
}
/**