Thanks.

For the most part, that's what I ended up with, but the thread 'stealing' a message will be quite hard to implement in Rust, I guess.
When using notmuch_query_search_messages, I was assuming the resulting individual messages to be owned by the query.
So, if at a later point in time, one uses notmuch_query_search_threads, will the ownership of a previous message abruptly be
transferred from query to thread?
I do want to be able to run *_destroy at some point :)

-Dirk


On Thu, 20 Dec 2018 at 10:11, David Bremner <david@tethera.net> wrote:
Dirk Van Haerenborgh <vhdirk@gmail.com> writes:


> For instance, when iterating messages from a thread: Can one still use a
> notmuch_message_t* when the thread is destroyed?
> Are the individual
> messages 'owned' by the thread, or only by the query? Same question for
> 'replies'.
>
> Could someone please shed some light on this? I'd very much appreciate it.

It's hierarchical (the underlying allocator is talloc). So threads are
owned by the corresponding query, and messages are owned by threads.

Assuming replies refers to notmuch_message_get_replies, then those are
owned by some thread as well.

Threads are somewhat lazily constructed, so there's a time where a
message is owned by a query before it is "stolen" by a thread.

This is all Carl's design, so hopefully he'll correct me if I said
anything outrageously wrong.

d