--- /dev/null
+Return-Path: <jani@nikula.org>\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 2F3F76DE1034\r
+ for <notmuch@notmuchmail.org>; Sun, 8 Nov 2015 09:38:30 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.997\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.997 tagged_above=-999 required=5 tests=[AWL=1.017, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01] 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 lxypank-ecVU for <notmuch@notmuchmail.org>;\r
+ Sun, 8 Nov 2015 09:38:27 -0800 (PST)\r
+Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com\r
+ [74.125.82.43]) by arlo.cworth.org (Postfix) with ESMTPS id B93FA6DE0A94 for\r
+ <notmuch@notmuchmail.org>; Sun, 8 Nov 2015 09:38:26 -0800 (PST)\r
+Received: by wmec201 with SMTP id c201so51961926wme.1\r
+ for <notmuch@notmuchmail.org>; Sun, 08 Nov 2015 09:38:24 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=nikula_org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+ :message-id:mime-version:content-type;\r
+ bh=IPfVi5lZu8luU0e/TxfLs9n4Y0/J/9foPDoiPiqSBUY=;\r
+ b=NPI3qM8iYrK7NGEjDGiZequAgKrJAniF+QmD7f+14rYh+DoJKUGA94ppUku6KoxYsA\r
+ itg9/O0Y99iFb3hqd9sfysEeoh4NXaoqKw36a1W/9gLBdBjSguiAA4/Av9TY7p6i1xBr\r
+ MUj4o7YQSZF9CawY8iq4R99lQ2t2yq6EajfNzQGSrReTpqka6maVYWO7wcX3Hz3N/EjS\r
+ YO4D5+1YvbIAROsi0tmmgBq007rcVZi4Ni6aUW82l6GzWplJFpqlW6mZT3gAYMVepWxP\r
+ 9Uspbx4+UiTeZ94x0OTO7bWhoW/LvHT+TBGI37z4rQR38m+AVZ4uw3tlJr8J6BTxiNsX\r
+ 9YBw==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:in-reply-to:references\r
+ :user-agent:date:message-id:mime-version:content-type;\r
+ bh=IPfVi5lZu8luU0e/TxfLs9n4Y0/J/9foPDoiPiqSBUY=;\r
+ b=LCjrsvm+x0DvFc9Uo3aFB+Sck0BQHtRg3geNdmCWU3jv9zrw3pxQQXucvVIk7xxL2p\r
+ a2JyZlF8AOAr2TvaWT3eh35NsdVVFGEcIxDsI44Q0KzAl03KnSdh+auZK58WX54YGGw6\r
+ Mj2TBCj/x4aOyrDZwhgHNd0Fpm6g8ZhwdNy6Ap/UMdbige0QRIQbOEqv8YMQ0DdVlelh\r
+ 1FAXQqS9svg9rz/Ckic1MnB3fypY1TNcSRzFl+CDHHvRec2okd6B6UfGpE4xMYZ28dL9\r
+ b5ZQJxaCUq3/VMQHW9T4+MgvFMfXFVO7fCJT11Vq54mizzt05Fcr7HvMmBs1trWP/p03\r
+ meuw==\r
+X-Gm-Message-State:\r
+ ALoCoQlINdg0fY98B5OFCDnkOERDq7vJqy6aDqsXg6IMkNqBRts/Zs29llzvi1FdvLTDgPDYjlcM\r
+X-Received: by 10.28.30.3 with SMTP id e3mr5769933wme.78.1447004304219;\r
+ Sun, 08 Nov 2015 09:38:24 -0800 (PST)\r
+Received: from localhost (mobile-access-5d6a91-125.dhcp.inet.fi.\r
+ [93.106.145.125])\r
+ by smtp.gmail.com with ESMTPSA id h189sm1444873wme.1.2015.11.08.09.38.23\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sun, 08 Nov 2015 09:38:23 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Steven Allen <steven@stebalien.com>, notmuch@notmuchmail.org\r
+Cc: Steven Allen <steven@stebalien.com>\r
+Subject: Re: [PATCH] Add a method to reparent threads to the database.\r
+In-Reply-To: <1446930269-4865-1-git-send-email-steven@stebalien.com>\r
+References: <1446408428-7703-1-git-send-email-steven@stebalien.com>\r
+ <1446930269-4865-1-git-send-email-steven@stebalien.com>\r
+User-Agent: Notmuch/0.21~rc3+3~g80a80a8 (http://notmuchmail.org) Emacs/24.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 08 Nov 2015 19:37:47 +0200\r
+Message-ID: <878u6875p0.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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 17:38:30 -0000\r
+\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
+\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
+\r
+I think this patch makes the situation slightly worse.\r
+\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
+\r
+BR,\r
+Jani.\r
+\r
+\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
+> \r
+> /**\r
+> + * Reparent a notmuch_thread_t object onto the database.\r
+> + *\r
+> + * Calling this function allows a notmuch_thread_t object to outlive its\r
+> + * query. The query will automatically be reclaimed when the database is\r
+> + * destroyed but if you want to free its memory before then, you should 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
+> -- \r
+> 2.6.2\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> https://notmuchmail.org/mailman/listinfo/notmuch\r