]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
lib: check talloc success in compact
[notmuch] / lib / database.cc
index 06f1c0a18043e2551c56290265a461f742ed39f5..7a8702e263c46985bb21818d3f8dd039e39799d6 100644 (file)
@@ -863,14 +863,17 @@ notmuch_database_compact (const char* path,
                          const char* backup_path,
                          notmuch_compact_status_cb_t status_cb)
 {
-    void *local = talloc_new (NULL);
-    NotmuchCompactor compactor(status_cb);
+    void *local;
     char *notmuch_path, *xapian_path, *compact_xapian_path;
     char *old_xapian_path = NULL;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
     notmuch_database_t *notmuch = NULL;
     struct stat statbuf;
 
+    local = talloc_new (NULL);
+    if (! local)
+       return NOTMUCH_STATUS_OUT_OF_MEMORY;
+
     ret = notmuch_database_open(path, NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch);
     if (ret) {
        goto DONE;
@@ -910,6 +913,8 @@ notmuch_database_compact (const char* path,
     }
 
     try {
+       NotmuchCompactor compactor(status_cb);
+
        compactor.set_renumber(false);
        compactor.add_source(xapian_path);
        compactor.set_destdir(compact_xapian_path);
@@ -944,7 +949,9 @@ DONE:
 }
 #else
 notmuch_status_t
-notmuch_database_compact_close (unused (notmuch_database_t *notmuch))
+notmuch_database_compact (unused (const char* path),
+                         unused (const char* backup_path),
+                         unused (notmuch_compact_status_cb_t status_cb))
 {
     fprintf (stderr, "notmuch was compiled against a xapian version lacking compaction support.\n");
     return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;