--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id A6BAA6DE1413\r
+ for <notmuch@notmuchmail.org>; Sun, 27 Sep 2015 08:35:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.108\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.108 tagged_above=-999 required=5 tests=[AWL=0.108]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id LOEeGvb0ryGC for <notmuch@notmuchmail.org>;\r
+ Sun, 27 Sep 2015 08:35:24 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id E4EFA6DE14FD\r
+ for <notmuch@notmuchmail.org>; Sun, 27 Sep 2015 08:35:23 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1ZgDyM-0008FV-2s; Sun, 27 Sep 2015 15:34:42 +0000\r
+Received: (nullmailer pid 11945 invoked by uid 1000); Sun, 27 Sep 2015\r
+ 15:32:11 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 8/9] lib: migrate thread.cc to new query_search API\r
+Date: Sun, 27 Sep 2015 12:32:02 -0300\r
+Message-Id: <1443367923-11867-9-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1443367923-11867-1-git-send-email-david@tethera.net>\r
+References: <1443367923-11867-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 27 Sep 2015 15:35:25 -0000\r
+\r
+here we rely on thread_id_query being attached to the local talloc\r
+context, so no new cleanup code is needed.\r
+---\r
+ lib/thread.cc | 9 ++++++---\r
+ 1 file changed, 6 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index c8e58c3..0c937d7 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -447,6 +447,7 @@ _notmuch_thread_create (void *ctx,\r
+ \r
+ notmuch_messages_t *messages;\r
+ notmuch_message_t *message;\r
++ notmuch_status_t status;\r
+ \r
+ seed_message = _notmuch_message_create (local, notmuch, seed_doc_id, NULL);\r
+ if (! seed_message)\r
+@@ -504,9 +505,11 @@ _notmuch_thread_create (void *ctx,\r
+ * oldest or newest subject is desired. */\r
+ notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST);\r
+ \r
+- /* XXX: this should use the _st version, but it needs an error path\r
+- */\r
+- for (messages = notmuch_query_search_messages (thread_id_query);\r
++ status = notmuch_query_search_messages_st (thread_id_query, &messages);\r
++ if (status)\r
++ goto DONE;\r
++\r
++ for (;\r
+ notmuch_messages_valid (messages);\r
+ notmuch_messages_move_to_next (messages))\r
+ {\r
+-- \r
+2.5.3\r
+\r