From: Steven Allen Date: Sat, 7 Nov 2015 21:04:29 +0000 (+1900) Subject: [PATCH] Add a method to reparent threads to the database. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=de2b01c24c93ddd2267d655aa271570fa50428de;p=notmuch-archives.git [PATCH] Add a method to reparent threads to the database. --- diff --git a/7e/7de187796bcb6f6320736bc7577f42a4671ed5 b/7e/7de187796bcb6f6320736bc7577f42a4671ed5 new file mode 100644 index 000000000..123408698 --- /dev/null +++ b/7e/7de187796bcb6f6320736bc7577f42a4671ed5 @@ -0,0 +1,109 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id BF51A6DE1343 + for ; Sat, 7 Nov 2015 13:04:45 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.681 +X-Spam-Level: +X-Spam-Status: No, score=-0.681 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, + T_FREEMAIL_FORGED_FROMDOMAIN=0.01, + T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6sxUEwiSP0kr for ; + Sat, 7 Nov 2015 13:04:43 -0800 (PST) +Received: from mail-vk0-f43.google.com (mail-vk0-f43.google.com + [209.85.213.43]) + by arlo.cworth.org (Postfix) with ESMTPS id 50E416DE1006 + for ; Sat, 7 Nov 2015 13:04:43 -0800 (PST) +Received: by vkfw189 with SMTP id w189so35685790vkf.2 + for ; Sat, 07 Nov 2015 13:04:42 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; + bh=XV38gCwswr3Z1qNgGfbC4k+fxluRzPJLD3DfyH7mRIw=; + b=XJTxmSgg0uCOlFszvI2l6Ga5IIgO2L5Hb4mLs/4oz/Qd9QzwSCAgP0dgr85ge23o+D + Uh38VIBLjapkGx2DV+zQK9x9ImF9isQhUkYos4SOtU4Jk8jJ+i17kUOfNYlAKV/LBETg + 4Sb9U3m4jNsdH7xjXI+My6ppXA2bXcquusXrEw8cOAKW4SUP8EQzIvo207jIQPV8KJRq + JCkk2r8wojxVCxZmMW221uWT7a4IZ3yA6v8oJLP7CAReit7QrvO07cYYrxtvVqgRp7Iw + IjhbfOx9bw4zo8zaLP7VCzwgsLQtHzMxbd+gVAwB1+5Zdye842xnUiOskEcefkonKirv + sXBA== +X-Received: by 10.31.160.5 with SMTP id j5mr22470137vke.107.1446930282057; + Sat, 07 Nov 2015 13:04:42 -0800 (PST) +Received: from localhost ([50.247.245.235]) + by smtp.gmail.com with ESMTPSA id k7sm5632937vki.8.2015.11.07.13.04.41 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 07 Nov 2015 13:04:41 -0800 (PST) +Sender: Steven +From: Steven Allen +To: notmuch@notmuchmail.org +Cc: Steven Allen +Subject: [PATCH] Add a method to reparent threads to the database. +Date: Sat, 7 Nov 2015 16:04:29 -0500 +Message-Id: <1446930269-4865-1-git-send-email-steven@stebalien.com> +X-Mailer: git-send-email 2.6.2 +In-Reply-To: <1446408428-7703-1-git-send-email-steven@stebalien.com> +References: <1446408428-7703-1-git-send-email-steven@stebalien.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 07 Nov 2015 21:04:45 -0000 + +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 +