--- /dev/null
+Return-Path: <stebalien@gmail.com>\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 7031A6DE103A\r
+ for <notmuch@notmuchmail.org>; Sun, 8 Nov 2015 11:16:09 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.637\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.637 tagged_above=-999 required=5 tests=[AWL=0.044,\r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001,\r
+ T_FREEMAIL_FORGED_FROMDOMAIN=0.01, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01]\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 kCIJmRHd6Dck for <notmuch@notmuchmail.org>;\r
+ Sun, 8 Nov 2015 11:16:03 -0800 (PST)\r
+Received: from mail-qg0-f49.google.com (mail-qg0-f49.google.com\r
+ [209.85.192.49])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 933AA6DE1034\r
+ for <notmuch@notmuchmail.org>; Sun, 8 Nov 2015 11:16:03 -0800 (PST)\r
+Received: by qgeb1 with SMTP id b1so75177603qge.1\r
+ for <notmuch@notmuchmail.org>; Sun, 08 Nov 2015 11:15:59 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=sender:date:from:to:cc:subject:message-id:references:mime-version\r
+ :content-type:content-disposition:in-reply-to:phone:user-agent;\r
+ bh=n8yB1vz70OTBpkFFUYAZlp1P4WxZZOYRwhoMSQfeRtY=;\r
+ b=DkftCSqDotLGkdcXvDfesqfdAR2zQzdoqdMU4/vx1Ynau5zf43fRQdKFpuSfhK2doJ\r
+ iG8tKDcnDE55Iuh6Sn9I01VEfK7pKdS0GG3LwtcFQS6bQjgOtZthGhZdm6MM4ajGvSOE\r
+ GgAddZMJeWyrJuNKUSSr9zd15M42UfAiWzmQKQS8oJlSV7mtsvtOixGcCcWbnVIm0cx6\r
+ 88QIzJAp46Hqzbz73vEjGQ+nu446TE/MqFGwlNllMewi1ihAdaa4NyyL60yt9KFkP1OU\r
+ Yt+X1jOusqDveXV2cXJKagDOSUloK7GjdEMJIEDKLNA5P0T0pPDrW9CiGiHk2Rgn7CmD\r
+ UGsw==\r
+X-Received: by 10.140.28.11 with SMTP id 11mr25339985qgy.94.1447010159288;\r
+ Sun, 08 Nov 2015 11:15:59 -0800 (PST)\r
+Received: from localhost (c-24-218-80-235.hsd1.ma.comcast.net.\r
+ [24.218.80.235]) by smtp.gmail.com with ESMTPSA id\r
+ b63sm3411616qka.31.2015.11.08.11.15.58 (version=TLSv1.2\r
+ cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2015 11:15:58\r
+ -0800 (PST)\r
+Sender: Steven <stebalien@gmail.com>\r
+Date: Sun, 8 Nov 2015 14:15:36 -0500\r
+From: Steven Allen <steven@stebalien.com>\r
+To: Jani Nikula <jani@nikula.org>\r
+Cc: notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] Add a method to reparent threads to the database.\r
+Message-ID: <20151108191536.GA3115@stebalien.com>\r
+References: <1446408428-7703-1-git-send-email-steven@stebalien.com>\r
+ <1446930269-4865-1-git-send-email-steven@stebalien.com>\r
+ <878u6875p0.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; micalg=pgp-sha256;\r
+ protocol="application/pgp-signature"; boundary="LZvS9be/3tNcYl/X"\r
+Content-Disposition: inline\r
+In-Reply-To: <878u6875p0.fsf@nikula.org>\r
+Phone: +1-310-433-5865\r
+X-PGP-Key: https://stebalien.com/assets/media/uploads/key.pgp\r
+X-PGP-Fingerprint: 327B 20CE 21EA 68CF A774 8675 7C92 3221 5899 410C\r
+User-Agent: Mutt/1.5.23.1 (2014-03-12)\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 08 Nov 2015 19:16:09 -0000\r
+\r
+\r
+--LZvS9be/3tNcYl/X\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+I'm writing high-level rust bindings for notmuch and would like to\r
+enable encapsulation of query logic. That is, I'd like to be able to\r
+write a function that performs a (set of) query(s) and returns a (or a\r
+set of) message(s)/thread(s). I can't do this currently because the\r
+messages/threads can't outlive the query. I could use reference counting\r
+to store the query until all messages/threads have been freed but that\r
+feels messy and shouldn't, strictly speaking, be necessary.\r
+\r
+On 11-08-15, Jani Nikula wrote:\r
+> On Sat, 07 Nov 2015, Steven Allen <steven@stebalien.com> wrote:\r
+> > This allows threads yielded from a query to outlive the query.\r
+>=20\r
+> We have a leaky abstraction in the interface. We don't properly define\r
+> object lifetimes and ownership, but we have slightly vague references to\r
+> them, and the users of the interface pretty much have to respect\r
+> them. We try to hide talloc and its concepts.\r
+>=20\r
+> I think this patch makes the situation slightly worse.\r
+>=20\r
+> I'd like to understand why this change is better than just holding on to\r
+> the query object. The memory saving is neglible.\r
+>=20\r
+> BR,\r
+> Jani.\r
+>=20\r
+>=20\r
+> > ---\r
+> > lib/notmuch.h | 11 +++++++++++\r
+> > lib/thread.cc | 6 ++++++\r
+> > 2 files changed, 17 insertions(+)\r
+> >\r
+> > diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+> > index 310a8b8..9a2869b 100644\r
+> > --- a/lib/notmuch.h\r
+> > +++ b/lib/notmuch.h\r
+> > @@ -1188,6 +1188,17 @@ notmuch_tags_t *\r
+> > notmuch_thread_get_tags (notmuch_thread_t *thread);\r
+> > =20\r
+> > /**\r
+> > + * Reparent a notmuch_thread_t object onto the database.\r
+> > + *\r
+> > + * Calling this function allows a notmuch_thread_t object to outlive i=\r
+ts\r
+> > + * query. The query will automatically be reclaimed when the database =\r
+is\r
+> > + * destroyed but if you want to free its memory before then, you shoul=\r
+d call\r
+> > + * notmuch_thread_destroy.\r
+> > + */\r
+> > +void\r
+> > +notmuch_thread_own (notmuch_thread_t *thread);\r
+> > +\r
+> > +/**\r
+> > * Destroy a notmuch_thread_t object.\r
+> > */\r
+> > void\r
+> > diff --git a/lib/thread.cc b/lib/thread.cc\r
+> > index 0c937d7..06fa155 100644\r
+> > --- a/lib/thread.cc\r
+> > +++ b/lib/thread.cc\r
+> > @@ -623,3 +623,9 @@ notmuch_thread_destroy (notmuch_thread_t *thread)\r
+> > {\r
+> > talloc_free (thread);\r
+> > }\r
+> > +\r
+> > +void\r
+> > +notmuch_thread_own (notmuch_thread_t *thread)\r
+> > +{\r
+> > + talloc_steal (thread->notmuch, thread);\r
+> > +}\r
+> > --=20\r
+> > 2.6.2\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > https://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+--=20\r
+Steven Allen\r
+(310) 433-5865\r
+((Do Not Email <honeypot@stebalien.com>))\r
+\r
+--LZvS9be/3tNcYl/X\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2\r
+\r
+iQIcBAEBCAAGBQJWP59VAAoJEGVqlrqQ0li+qUUP+wYIs9NZRkWMZqloj7vOQk8+\r
+AYPbtMftSXmyRg2F96wGAF3rM3NsYflVWT2qHvI6afjXpbVoq4ewVEFsN2/6lyVJ\r
+AiEFk6YwNfozUEwY4WOjZk977A07DOhY4Yw/W0wYlE9C2F+nhgSD2hlQ8ASzZDPe\r
+PG1JRe+Z9Iy2SdKZSvxn3bkSU1T+BqqCh6OETdO3lD3cPDRXvlO0c5oLdin8d5p4\r
+JmD6V8wlDGbpCDBym8i39QuQKwPN12F3wtfv4XEBaxnuQQDYN89iZlFEoqbvuUY0\r
+6q1Rn3pYZMJqf2eQOZqT9BsHu87Xl4q3lTypS6D1m4bMrFdLy4Vx0wzTrCYOnwo3\r
+b3ZP9dSaCCIfVnvXhA6lBrbHDEmkCEyVtL4nQCWXYb7awvSIopmHNUjVC2idF/LN\r
++PM8P3FoMcwnGzCwuMOk9GrUws8wLRBFh2jt95PILJMJ+bOyH5r718BuST89pySp\r
+tA1f99hupV+I2URPQbinpOq7ZODAA2dEG0O4bNm3VhQyd3UGZgMSuWspjiOJOKo3\r
+p1ZBeYX/Gn8+q08uHNpQ4SyZj1cLmhjDbUl1nH3ktws+dHVuGfNS10H2ZbID1f6U\r
+KMgcZZc+p6R4JBpB2UQ/jzHhrPzP6WAIyuLNCYi0gCCeQKGQz2QVIyv8tL2t0tnP\r
+AVbzvXfdrtdfr36L3/r6\r
+=on55\r
+-----END PGP SIGNATURE-----\r
+\r
+--LZvS9be/3tNcYl/X--\r