]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/ruby/database.c
ruby: split database close and destroy
[notmuch] / bindings / ruby / database.c
index 1cf4e4e27c170e45f2e332b3e2d5e61c93646a9d..9c3dbd96f0b292f856c2ccca2448b8483503a568 100644 (file)
@@ -26,6 +26,19 @@ notmuch_rb_database_alloc (VALUE klass)
     return Data_Wrap_Notmuch_Object (klass, &notmuch_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, &notmuch_rb_database_type);
+
+    return Qnil;
+}
+
 /*
  * call-seq: Notmuch::Database.new(path [, {:create => false, :mode => Notmuch::MODE_READ_ONLY}]) => DB
  *
@@ -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, &notmuch_rb_database_type);
+
+    Data_Get_Notmuch_Database (self, db);
+
+    ret = notmuch_database_close (db);
     notmuch_rb_status_raise (ret);
 
     return Qnil;