X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fruby%2Fdatabase.c;h=9c3dbd96f0b292f856c2ccca2448b8483503a568;hb=3f27cce71f9f154cb0c2134c32d41c31eb62a239;hp=d6c804ac244bb0693ff78e493fe4699cb7e33462;hpb=814abafc3e4280de115d4bc0ac01f8d026a0a7f9;p=notmuch diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index d6c804ac..9c3dbd96 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -26,6 +26,19 @@ notmuch_rb_database_alloc (VALUE klass) return Data_Wrap_Notmuch_Object (klass, ¬much_rb_database_type, NULL); } +/* + * call-seq: DB.destroy => nil + * + * Destroys the database, freeing all resources allocated for it. + */ +VALUE +notmuch_rb_database_destroy (VALUE self) +{ + notmuch_rb_object_destroy (self, ¬much_rb_database_type); + + return Qnil; +} + /* * call-seq: Notmuch::Database.new(path [, {:create => false, :mode => Notmuch::MODE_READ_ONLY}]) => DB * @@ -81,7 +94,7 @@ notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE self) ret = notmuch_database_open (path, mode, &database); notmuch_rb_status_raise (ret); - DATA_PTR (self) = database; + DATA_PTR (self) = notmuch_rb_object_create (database, "notmuch_rb_database"); return self; } @@ -113,8 +126,12 @@ notmuch_rb_database_open (int argc, VALUE *argv, VALUE klass) VALUE notmuch_rb_database_close (VALUE self) { + notmuch_database_t *db; notmuch_status_t ret; - ret = notmuch_rb_object_destroy (self, ¬much_rb_database_type); + + Data_Get_Notmuch_Database (self, db); + + ret = notmuch_database_close (db); notmuch_rb_status_raise (ret); return Qnil;