Re: [PATCH 6/7] ruby: Use notmuch_database_destroy instead of notmuch_database_close
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 23 Apr 2012 12:36:33 +0000 (15:36 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:39 +0000 (09:46 -0800)
31/328ef0c6912fcae555d85fcd3423fd1b9c34cd [new file with mode: 0644]

diff --git a/31/328ef0c6912fcae555d85fcd3423fd1b9c34cd b/31/328ef0c6912fcae555d85fcd3423fd1b9c34cd
new file mode 100644 (file)
index 0000000..df67754
--- /dev/null
@@ -0,0 +1,123 @@
+Return-Path: <felipe.contreras@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 olra.theworths.org (Postfix) with ESMTP id 20E02431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 05:36:35 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id CA1nX8JehwqI for <notmuch@notmuchmail.org>;\r
+       Mon, 23 Apr 2012 05:36:34 -0700 (PDT)\r
+Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com\r
+       [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 5E5BC431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 05:36:34 -0700 (PDT)\r
+Received: by eaa1 with SMTP id 1so4845805eaa.26\r
+       for <notmuch@notmuchmail.org>; Mon, 23 Apr 2012 05:36:33 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
+       :cc:content-type:content-transfer-encoding;\r
+       bh=sS9SukCX68dPRsX6RcHM/nvXw/fnLOy6II5Njn4RAuk=;\r
+       b=BvpA2yyuI45RPtdhvXhHNWasLjEb0LNFWhlElSfuUEUlpXcGMTXJuyQVMyoyMBCl/O\r
+       XB7yqlsZQW5wuK4xmtQa4i72oN5xh/B7MZev1WGCHPSdAO4Hy69WKVuxot4V9TGAu/Mr\r
+       qrhkIqxYEPfN0rUWzpcaLysmuhiuxUAs9A7iYbkzwsaCgpQkP4tx6nIuAKqg+q7IROiF\r
+       LMAxGfaG0m1CfQXDfxePX077d8JJkIdNllT9ZF9wb6WNDp1mczOkhoTtME0mlmuWVGYj\r
+       5LoOVo4MAij6S+HkgtW0dshfSaQYU1ef5JoZw4A6g1u/JfokF2C9QQbBYna3U/Nusrnd\r
+       wjBA==\r
+MIME-Version: 1.0\r
+Received: by 10.14.96.129 with SMTP id r1mr2524813eef.86.1335184593098; Mon,\r
+       23 Apr 2012 05:36:33 -0700 (PDT)\r
+Received: by 10.213.103.18 with HTTP; Mon, 23 Apr 2012 05:36:33 -0700 (PDT)\r
+In-Reply-To:\r
+ <1335096477-27537-6-git-send-email-4winter@informatik.uni-hamburg.de>\r
+References: <20120422120620.26225.40778@thinkbox.jade-hamburg.de>\r
+       <1335096477-27537-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+       <1335096477-27537-6-git-send-email-4winter@informatik.uni-hamburg.de>\r
+Date: Mon, 23 Apr 2012 15:36:33 +0300\r
+Message-ID:\r
+ <CAMP44s0KHJz6AxUfRjEUk5heOEFVyT2NixpFNb5GZakXaoLAKw@mail.gmail.com>\r
+Subject: Re: [PATCH 6/7] ruby: Use notmuch_database_destroy instead of\r
+       notmuch_database_close\r
+From: Felipe Contreras <felipe.contreras@gmail.com>\r
+To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 23 Apr 2012 12:36:35 -0000\r
+\r
+Hi,\r
+\r
+On Sun, Apr 22, 2012 at 3:07 PM, Justus Winter\r
+<4winter@informatik.uni-hamburg.de> wrote:\r
+> Adapt the ruby bindings to the notmuch_database_close split.\r
+>\r
+> Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+> ---\r
+> =C2=A0bindings/ruby/database.c | =C2=A0 =C2=A02 +-\r
+> =C2=A01 file changed, 1 insertion(+), 1 deletion(-)\r
+>\r
+> diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c\r
+> index 982fd59..ba9a139 100644\r
+> --- a/bindings/ruby/database.c\r
+> +++ b/bindings/ruby/database.c\r
+> @@ -110,7 +110,7 @@ notmuch_rb_database_close (VALUE self)\r
+> =C2=A0 =C2=A0 notmuch_database_t *db;\r
+>\r
+> =C2=A0 =C2=A0 Data_Get_Notmuch_Database (self, db);\r
+> - =C2=A0 =C2=A0notmuch_database_close (db);\r
+> + =C2=A0 =C2=A0notmuch_database_destroy (db);\r
+> =C2=A0 =C2=A0 DATA_PTR (self) =3D NULL;\r
+>\r
+> =C2=A0 =C2=A0 return Qnil;\r
+> --\r
+\r
+I don't think this is the right approach. If database_destroy truly\r
+destroys the object, then we would want to do it only at garbage\r
+collection, when it's not accessible any more. What if I want to\r
+re-use the database from the Ruby code?\r
+\r
+This would probably be better:\r
+\r
+-- a/bindings/ruby/database.c\r
++++ b/bindings/ruby/database.c\r
+@@ -20,10 +20,16 @@\r
+\r
+ #include "defs.h"\r
+\r
++static void\r
++database_free (void *p)\r
++{\r
++    notmuch_database_destroy (p);\r
++}\r
++\r
+ VALUE\r
+ notmuch_rb_database_alloc (VALUE klass)\r
+ {\r
+-    return Data_Wrap_Struct (klass, NULL, NULL, NULL);\r
++    return Data_Wrap_Struct (klass, NULL, database_free, NULL);\r
+ }\r
+\r
+ /*\r
+\r
+--=20\r
+Felipe Contreras\r