From dc3cc18bf0c649dfdb280a7afbb3b6039101f281 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 3 Sep 2018 18:02:25 -0300 Subject: [PATCH] lib: add _notmuch_message_list_empty There is no public notmuch_message_list_t public interface, so to this is added to the private API. We use it immediately in thread.cc; future commits will use it further. --- lib/messages.c | 9 +++++++++ lib/notmuch-private.h | 3 +++ lib/thread.cc | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/messages.c b/lib/messages.c index a88f974f..ba8a9777 100644 --- a/lib/messages.c +++ b/lib/messages.c @@ -56,6 +56,15 @@ _notmuch_message_list_add_message (notmuch_message_list_t *list, list->tail = &node->next; } +bool +_notmuch_message_list_empty (notmuch_message_list_t *list) +{ + if (list == NULL) + return TRUE; + + return (list->head == NULL); +} + notmuch_messages_t * _notmuch_messages_create (notmuch_message_list_t *list) { diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 02cc0e09..590a3451 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -477,6 +477,9 @@ struct _notmuch_messages { notmuch_message_list_t * _notmuch_message_list_create (const void *ctx); +bool +_notmuch_message_list_empty (notmuch_message_list_t *list); + void _notmuch_message_list_add_message (notmuch_message_list_t *list, notmuch_message_t *message); diff --git a/lib/thread.cc b/lib/thread.cc index 6d15c49b..a0ce4be3 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -425,7 +425,7 @@ _resolve_thread_relationships (notmuch_thread_t *thread) if (first_node) { message = first_node->message; in_reply_to = _notmuch_message_get_in_reply_to (message); - if (thread->toplevel_list->head && + if (! _notmuch_message_list_empty (thread->toplevel_list) && in_reply_to && strlen (in_reply_to) && g_hash_table_lookup_extended (thread->message_hash, in_reply_to, NULL,