]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/ruby/database.c
Merge tag 'debian/0.32.3-1'
[notmuch] / bindings / ruby / database.c
index d6c804ac244bb0693ff78e493fe4699cb7e33462..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
  *
@@ -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, &notmuch_rb_database_type);
+
+    Data_Get_Notmuch_Database (self, db);
+
+    ret = notmuch_database_close (db);
     notmuch_rb_status_raise (ret);
 
     return Qnil;