[PATCH] Add a method to reparent threads to the database.
Steven Allen
steven at stebalien.com
Sat Nov 7 13:04:29 PST 2015
This allows threads yielded from a query to outlive the query.
---
lib/notmuch.h | 11 +++++++++++
lib/thread.cc | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 310a8b8..9a2869b 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1188,6 +1188,17 @@ notmuch_tags_t *
notmuch_thread_get_tags (notmuch_thread_t *thread);
/**
+ * Reparent a notmuch_thread_t object onto the database.
+ *
+ * Calling this function allows a notmuch_thread_t object to outlive its
+ * query. The query will automatically be reclaimed when the database is
+ * destroyed but if you want to free its memory before then, you should call
+ * notmuch_thread_destroy.
+ */
+void
+notmuch_thread_own (notmuch_thread_t *thread);
+
+/**
* Destroy a notmuch_thread_t object.
*/
void
diff --git a/lib/thread.cc b/lib/thread.cc
index 0c937d7..06fa155 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -623,3 +623,9 @@ notmuch_thread_destroy (notmuch_thread_t *thread)
{
talloc_free (thread);
}
+
+void
+notmuch_thread_own (notmuch_thread_t *thread)
+{
+ talloc_steal (thread->notmuch, thread);
+}
--
2.6.2
More information about the notmuch
mailing list