1 Return-Path: <stebalien@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 967AF6DE0AC2
\r
6 for <notmuch@notmuchmail.org>; Sun, 1 Nov 2015 12:07:21 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.681 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,
\r
13 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001,
\r
14 T_FREEMAIL_FORGED_FROMDOMAIN=0.01,
\r
15 T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled
\r
16 Received: from arlo.cworth.org ([127.0.0.1])
\r
17 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
18 with ESMTP id rTsOnTnQh8xA for <notmuch@notmuchmail.org>;
\r
19 Sun, 1 Nov 2015 12:07:19 -0800 (PST)
\r
20 Received: from mail-qg0-f42.google.com (mail-qg0-f42.google.com
\r
22 by arlo.cworth.org (Postfix) with ESMTPS id 192FD6DE0A9A
\r
23 for <notmuch@notmuchmail.org>; Sun, 1 Nov 2015 12:07:19 -0800 (PST)
\r
24 Received: by qgeo38 with SMTP id o38so102660784qge.0
\r
25 for <notmuch@notmuchmail.org>; Sun, 01 Nov 2015 12:07:17 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=sender:from:to:cc:subject:date:message-id;
\r
28 bh=+IAkOe57Zmn0FWAMdKVUkWgelWIKDRw8+6Dn8ePS3Ns=;
\r
29 b=vBYH3h0HNeBqVkAZEkF4o7i75IhmZiWB9o3nUQ018anMZsBYH0Rle/VBdVy/LSPU+j
\r
30 c8MRZuVgTOVZVDnKYYd76pLte5jqa5hysSnfq0MwiILl91rp2Opb/E+HSumwpBl2lerj
\r
31 hFuJMJQaBGteH0AFR7EXCkaSLSVWVQoskIRxtO6eG6fh+NPXGsnJN9qqf5ioIZeawv9h
\r
32 lfmaXonw7uDUPROl7DQz6qFoHMo9ZLBlDgRaYrcekxRHtJA+gYJOK/B7AzoXCfhe1bqN
\r
33 4hd8nQBfEedY2QSrB/o8aUk9LFBi1mrnE9/feQRJrZ1NSNYEEaYm3wBILHya9ZSrWpJ/
\r
35 X-Received: by 10.140.44.33 with SMTP id f30mr24737950qga.30.1446408436914;
\r
36 Sun, 01 Nov 2015 12:07:16 -0800 (PST)
\r
37 Received: from localhost (c-24-218-80-235.hsd1.ma.comcast.net.
\r
38 [24.218.80.235]) by smtp.gmail.com with ESMTPSA id
\r
39 108sm786068qgz.17.2015.11.01.12.07.16 (version=TLSv1.2
\r
40 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Nov 2015 12:07:16
\r
42 Sender: Steven <stebalien@gmail.com>
\r
43 From: Steven Allen <steven@stebalien.com>
\r
44 To: notmuch@notmuchmail.org
\r
45 Cc: Steven Allen <steven@stebalien.com>
\r
46 Subject: [PATCH] Add method to reparent of message to the database.
\r
47 Date: Sun, 1 Nov 2015 15:07:08 -0500
\r
48 Message-Id: <1446408428-7703-1-git-send-email-steven@stebalien.com>
\r
49 X-Mailer: git-send-email 2.6.2
\r
50 X-BeenThere: notmuch@notmuchmail.org
\r
51 X-Mailman-Version: 2.1.20
\r
53 List-Id: "Use and development of the notmuch mail system."
\r
54 <notmuch.notmuchmail.org>
\r
55 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
58 List-Post: <mailto:notmuch@notmuchmail.org>
\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
60 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
62 X-List-Received-Date: Sun, 01 Nov 2015 20:07:21 -0000
\r
64 Currently, a message is owned by its iterator (messages object) and,
\r
65 ultimately, its query. This unfortunately makes encapsulating query
\r
66 logic difficult because there is no way to return a message after
\r
67 disposing of the query used to find the message (other than looking it
\r
68 up again in the database by id).
\r
70 This patch adds a function `notmuch_message_own` that reparents a
\r
71 message onto the database making it the user's job to destroy it.
\r
73 lib/message.cc | 6 ++++++
\r
74 lib/notmuch.h | 12 ++++++++++++
\r
75 2 files changed, 18 insertions(+)
\r
77 diff --git a/lib/message.cc b/lib/message.cc
\r
78 index 26b5e76..014363f 100644
\r
79 --- a/lib/message.cc
\r
80 +++ b/lib/message.cc
\r
81 @@ -1657,6 +1657,12 @@ notmuch_message_thaw (notmuch_message_t *message)
\r
85 +notmuch_message_own (notmuch_message_t *message)
\r
87 + talloc_steal(message->notmuch, message);
\r
91 notmuch_message_destroy (notmuch_message_t *message)
\r
93 talloc_free (message);
\r
94 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
95 index 310a8b8..c80d7aa 100644
\r
98 @@ -1629,6 +1629,18 @@ notmuch_message_freeze (notmuch_message_t *message);
\r
100 notmuch_message_thaw (notmuch_message_t *message);
\r
104 + * Reparent a notmuch_message_t object onto the database.
\r
106 + * Calling this function allows a notmuch_message_t object to outlive its
\r
107 + * query. The message will automatically be reclaimed when the database is
\r
108 + * destroyed but if you want to free its memory before then, you should call
\r
109 + * notmuch_message_destroy.
\r
112 +notmuch_message_own (notmuch_message_t *message);
\r
115 * Destroy a notmuch_message_t object.
\r