+notmuch_database_t *
+_alloc_notmuch ()
+{
+ notmuch_database_t *notmuch;
+
+ notmuch = talloc_zero (NULL, notmuch_database_t);
+ if (! notmuch)
+ return NULL;
+
+ notmuch->exception_reported = false;
+ notmuch->status_string = NULL;
+ notmuch->writable_xapian_db = NULL;
+ notmuch->atomic_nesting = 0;
+ notmuch->view = 1;
+ return notmuch;
+}
+
+static void
+_set_database_path (notmuch_database_t *notmuch,
+ const char *database_path)
+{
+ char *path = talloc_strdup (notmuch, database_path);
+
+ strip_trailing (path, '/');
+
+ _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path);
+}
+
+static void
+_init_libs ()
+{
+
+ static int initialized = 0;
+
+ /* Initialize the GLib type system and threads */
+#if ! GLIB_CHECK_VERSION (2, 35, 1)
+ g_type_init ();
+#endif
+
+ /* Initialize gmime */
+ if (! initialized) {
+ g_mime_init ();
+ initialized = 1;
+ }
+}
+