Pointer ownership

David Bremner david at tethera.net
Sun Dec 16 15:22:27 PST 2018


Dirk Van Haerenborgh <vhdirk at 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





More information about the notmuch mailing list