1 Return-Path: <jani@nikula.org>
\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 olra.theworths.org (Postfix) with ESMTP id 2E138431FAF
\r
6 for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 14:41:18 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id JzGigM5Zzgo6 for <notmuch@notmuchmail.org>;
\r
16 Sun, 16 Dec 2012 14:41:17 -0800 (PST)
\r
17 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com
\r
18 [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 40723431FAE
\r
21 for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 14:41:17 -0800 (PST)
\r
22 Received: by mail-lb0-f181.google.com with SMTP id ge1so4083048lbb.26
\r
23 for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 14:41:15 -0800 (PST)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=from:to:cc:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type:x-gm-message-state;
\r
28 bh=cqaFOzs62Te1J0RpDPkl6NQStKZTCgly1GYCqm/9AMQ=;
\r
29 b=HJETT2P+6f+L0VKblXINRJyn7Yrett/KjUYEYZUZ0qp/Npx8wn/B4l8CnQsHD7PySP
\r
30 bKw/GhEyIo/Uyzi38eRaESPPW58FgixubO/ViPufskPNjRJY64OoWvtKuFtq1KrsUFIB
\r
31 w3kSXDRuBGXQ3A7F71EHMQbZMFkkl9Lhc8TjJdLqUhGq3hDzcPsUiN7cQq5ti4K3EC3C
\r
32 yMXoOBTwGEmOCzcmDo+w3gODVfToIq5RwQAlLRwR/Aqa4QOP/TDa5YvG6D8rcNNkt7TD
\r
33 KY4YI9KPfAqfAwHZHMmp37iii4EvEXCVFMmgszJoRNUUDz9EyoZWaDySgUtOKK0WzLRg
\r
35 Received: by 10.112.83.100 with SMTP id p4mr5048275lby.96.1355697675705;
\r
36 Sun, 16 Dec 2012 14:41:15 -0800 (PST)
\r
37 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPS id ne2sm4136684lab.10.2012.12.16.14.41.13
\r
40 (version=SSLv3 cipher=OTHER); Sun, 16 Dec 2012 14:41:14 -0800 (PST)
\r
41 From: Jani Nikula <jani@nikula.org>
\r
42 To: david@tethera.net, notmuch@notmuchmail.org
\r
43 Subject: Re: [PATCH 3/3] notmuch-restore: allocate a temporary talloc context
\r
44 for each line parsed.
\r
45 In-Reply-To: <1355688997-19164-4-git-send-email-david@tethera.net>
\r
46 References: <1355688997-19164-1-git-send-email-david@tethera.net>
\r
47 <1355688997-19164-4-git-send-email-david@tethera.net>
\r
48 User-Agent: Notmuch/0.14+138~g7041c56 (http://notmuchmail.org) Emacs/23.4.1
\r
50 Date: Mon, 17 Dec 2012 00:41:12 +0200
\r
51 Message-ID: <87ip81pqlz.fsf@nikula.org>
\r
53 Content-Type: text/plain; charset=us-ascii
\r
55 ALoCoQmY0f2V6oBOtXX0PPWxxSqtiNu9/NXE8l70UadLGl939ySkZwfwbeIzsj/OC9XZ7gYAux8Z
\r
56 Cc: David Bremner <bremner@debian.org>
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Sun, 16 Dec 2012 22:41:18 -0000
\r
71 On Sun, 16 Dec 2012, david@tethera.net wrote:
\r
72 > From: David Bremner <bremner@debian.org>
\r
74 > This lets the high level code in notmuch restore be ignorant about
\r
75 > what the lower level code is doing as far as allocating memory.
\r
77 > notmuch-restore.c | 12 ++++++++++--
\r
78 > 1 file changed, 10 insertions(+), 2 deletions(-)
\r
80 > diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
81 > index 4b76d83..52e7ecb 100644
\r
82 > --- a/notmuch-restore.c
\r
83 > +++ b/notmuch-restore.c
\r
84 > @@ -122,6 +122,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
85 > char *input_file_name = NULL;
\r
86 > FILE *input = stdin;
\r
87 > char *line = NULL;
\r
88 > + void *line_ctx = NULL;
\r
92 > @@ -205,10 +206,11 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
94 > char *query_string;
\r
96 This patch only works on top of the batch tagging series, because
\r
97 there's still one continue statement in the "id:" prefix check. But you
\r
98 could make it work for both, *and* keep the slightly more intuitive ret
\r
99 checking order if you did (yes, the slightly counter-intuitive):
\r
101 if (line_ctxt != NULL)
\r
102 talloc_free (line_ctx);
\r
106 > + line_ctx = talloc_new (ctx);
\r
107 > if (input_format == DUMP_FORMAT_SUP) {
\r
108 > - ret = parse_sup_line (ctx, line, &query_string, tag_ops);
\r
109 > + ret = parse_sup_line (line_ctx, line, &query_string, tag_ops);
\r
111 > - ret = parse_tag_line (ctx, line, TAG_FLAG_BE_GENEROUS,
\r
112 > + ret = parse_tag_line (line_ctx, line, TAG_FLAG_BE_GENEROUS,
\r
113 > &query_string, tag_ops);
\r
116 > @@ -238,8 +240,14 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
120 > + talloc_free (line_ctx);
\r
121 > + /* setting to NULL is important to avoid a double free */
\r
122 > + line_ctx = NULL;
\r
124 ...removed the above lines here.
\r
126 Otherwise I think you'll need a temporary goto until the batch tagging
\r
127 series. (I'm fine with that too.)
\r
129 Overall the series LGTM, and I like how this dodges the query_string
\r
130 alloc/free problem altogether.
\r
135 > } while ((line_len = getline (&line, &line_size, input)) != -1);
\r
137 > + if (line_ctx != NULL)
\r
138 > + talloc_free (line_ctx);
\r
140 > if (input_format == DUMP_FORMAT_SUP)
\r
141 > regfree (®ex);
\r
146 > _______________________________________________
\r
147 > notmuch mailing list
\r
148 > notmuch@notmuchmail.org
\r
149 > http://notmuchmail.org/mailman/listinfo/notmuch
\r