]> git.cworth.org Git - notmuch/blobdiff - bindings/ruby/defs.h
ruby: new notmuch_rb_object_destroy() helper
[notmuch] / bindings / ruby / defs.h
index fa7b9515c9a8347e895a596b9a3f6b136925114a..9860ee17d9479e1bc1101978585ed986e0e704c1 100644 (file)
@@ -105,6 +105,21 @@ extern const rb_data_type_t notmuch_rb_tags_type;
 #define Data_Get_Notmuch_Tags(obj, ptr) \
     Data_Get_Notmuch_Object ((obj), &notmuch_rb_tags_type, (ptr))
 
+static inline notmuch_status_t
+notmuch_rb_object_destroy (VALUE rb_object, const rb_data_type_t *type)
+{
+    void *nm_object;
+    notmuch_status_t ret;
+
+    Data_Get_Notmuch_Object (rb_object, type, nm_object);
+
+    /* Call the corresponding notmuch_*_destroy function */
+    ret = ((notmuch_status_t (*)(void *)) type->data) (nm_object);
+    DATA_PTR (rb_object) = NULL;
+
+    return ret;
+}
+
 /* status.c */
 void
 notmuch_rb_status_raise (notmuch_status_t status);