2012/4/23 Felipe Contreras <felipe.contreras at gmail.com>:
> If the Ruby code does not manually close the database, we need to make
> sure it's closed when garbage collected.
>
> In Ruby, users are not _required_ to close, the garbage collector should
> take care of that.
>
> Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
> ---
> ?bindings/ruby/database.c | ? ?8 +++++++-
> ?1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
> index 982fd59..7b2ed47 100644
> --- 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_close (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);
> ?}
>
> ?/*
> --
> 1.7.10
>

I'd rather not do this.
Please read: http://comments.gmane.org/gmane.comp.lang.ruby.general/320324

        -alip

Reply via email to