[PATCH 1/4] lib/open: use local talloc context in n_d_create_with_config

Subject: [PATCH 1/4] lib/open: use local talloc context in n_d_create_with_config

Date: Sat, 6 Mar 2021 09:49:31 -0400

To: notmuch@notmuchmail.org

Cc: David Bremner

From: David Bremner


This better matches the memory allocation semantics in
notmuch_database_open_with_config.
---
 lib/open.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/open.cc b/lib/open.cc
index 3b86065b..3b66d2eb 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -423,6 +423,7 @@ notmuch_database_create_with_config (const char *database_path,
     GKeyFile *key_file = NULL;
     struct stat st;
     int err;
+    void *local = talloc_new (NULL);
 
     if ((status = _choose_database_path (config_path, profile, &key_file, &database_path, &message)))
 	goto DONE;
@@ -443,7 +444,7 @@ notmuch_database_create_with_config (const char *database_path,
 	goto DONE;
     }
 
-    notmuch_path = talloc_asprintf (NULL, "%s/%s", database_path, ".notmuch");
+    notmuch_path = talloc_asprintf (local, "%s/%s", database_path, ".notmuch");
 
     err = mkdir (notmuch_path, 0755);
     if (err) {
@@ -479,8 +480,7 @@ notmuch_database_create_with_config (const char *database_path,
     }
 
   DONE:
-    if (notmuch_path)
-	talloc_free (notmuch_path);
+    talloc_free (local);
 
     if (message) {
 	if (status_string)
-- 
2.30.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: