]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
notmuch_tags_advance: Make safe against excessive calls.
[notmuch] / lib / database.cc
index 4524016b37aecb1d0ffbacfbe72d4b5c8b03b94d..4e49e53f9c883a1d14ca0daa9e27e022f582d7b1 100644 (file)
@@ -107,7 +107,6 @@ prefix_t BOOLEAN_PREFIX_INTERNAL[] = {
     { "ref", "XREFERENCE" },
     { "replyto", "XREPLYTO" },
     { "timestamp", "XTIMESTAMP" },
-    { "contact", "XCONTACT" }
 };
 
 prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
@@ -391,22 +390,6 @@ parse_references (void *ctx,
     }
 }
 
-char *
-notmuch_database_default_path (void)
-{
-    char *path;
-
-    if (getenv ("NOTMUCH_BASE"))
-       return strdup (getenv ("NOTMUCH_BASE"));
-
-    if (asprintf (&path, "%s/mail", getenv ("HOME")) == -1) {
-       fprintf (stderr, "Out of memory.\n");
-       return xstrdup("");
-    }
-
-    return path;
-}
-
 notmuch_database_t *
 notmuch_database_create (const char *path)
 {
@@ -414,10 +397,11 @@ notmuch_database_create (const char *path)
     char *notmuch_path = NULL;
     struct stat st;
     int err;
-    char *local_path = NULL;
 
-    if (path == NULL)
-       path = local_path = notmuch_database_default_path ();
+    if (path == NULL) {
+       fprintf (stderr, "Error: Cannot create a database for a NULL path.\n");
+       goto DONE;
+    }
 
     err = stat (path, &st);
     if (err) {
@@ -447,8 +431,6 @@ notmuch_database_create (const char *path)
   DONE:
     if (notmuch_path)
        talloc_free (notmuch_path);
-    if (local_path)
-       free (local_path);
 
     return notmuch;
 }
@@ -460,12 +442,8 @@ notmuch_database_open (const char *path)
     char *notmuch_path = NULL, *xapian_path = NULL;
     struct stat st;
     int err;
-    char *local_path = NULL;
     unsigned int i;
 
-    if (path == NULL)
-       path = local_path = notmuch_database_default_path ();
-
     if (asprintf (&notmuch_path, "%s/%s", path, ".notmuch") == -1) {
        notmuch_path = NULL;
        fprintf (stderr, "Out of memory\n");
@@ -520,8 +498,6 @@ notmuch_database_open (const char *path)
     }
     
   DONE:
-    if (local_path)
-       free (local_path);
     if (notmuch_path)
        free (notmuch_path);
     if (xapian_path)