*database = notmuch;
else
talloc_free (notmuch);
+
+ if (notmuch)
+ notmuch->open = true;
+
return status;
}
/* Many Xapian objects (and thus notmuch objects) hold references to
* the database, so merely deleting the database may not suffice to
* close it. Thus, we explicitly close it here. */
- if (notmuch->xapian_db != NULL) {
+ if (notmuch->open) {
try {
/* If there's an outstanding transaction, it's unclear if
* closing the Xapian database commits everything up to
}
}
}
-
- delete notmuch->term_gen;
- notmuch->term_gen = NULL;
- delete notmuch->query_parser;
- notmuch->query_parser = NULL;
- delete notmuch->xapian_db;
- notmuch->xapian_db = NULL;
- delete notmuch->value_range_processor;
- notmuch->value_range_processor = NULL;
- delete notmuch->date_range_processor;
- notmuch->date_range_processor = NULL;
- delete notmuch->last_mod_range_processor;
- notmuch->last_mod_range_processor = NULL;
-
+ notmuch->open = false;
return status;
}
notmuch_status_t status;
status = notmuch_database_close (notmuch);
+
+ delete notmuch->term_gen;
+ notmuch->term_gen = NULL;
+ delete notmuch->query_parser;
+ notmuch->query_parser = NULL;
+ delete notmuch->xapian_db;
+ notmuch->xapian_db = NULL;
+ delete notmuch->value_range_processor;
+ notmuch->value_range_processor = NULL;
+ delete notmuch->date_range_processor;
+ notmuch->date_range_processor = NULL;
+ delete notmuch->last_mod_range_processor;
+ notmuch->last_mod_range_processor = NULL;
+
talloc_free (notmuch);
return status;