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