From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eJbREH54LWDwFQAA0tVLHw (envelope-from ) for ; Wed, 17 Feb 2021 20:11:42 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id cDWtDH54LWDLKgAA1q6Kng (envelope-from ) for ; Wed, 17 Feb 2021 20:11:42 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0222621395 for ; Wed, 17 Feb 2021 21:11:42 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5DB2826B8F; Wed, 17 Feb 2021 15:11:14 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 101B41FBB5 for ; Wed, 17 Feb 2021 15:10:57 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id E31376067D; Wed, 17 Feb 2021 15:10:56 -0500 (EST) Received: (nullmailer pid 2021428 invoked by uid 1000); Wed, 17 Feb 2021 20:10:50 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 11/21] lib/open: use _finish_open in n_d_create_with_config Date: Wed, 17 Feb 2021 16:10:35 -0400 Message-Id: <20210217201045.2021106-12-david@tethera.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210217201045.2021106-1-david@tethera.net> References: <20210217201045.2021106-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: VF6WVCI55ELXZE3IJ5O2REEMBKY5J7VK X-Message-ID-Hash: VF6WVCI55ELXZE3IJ5O2REEMBKY5J7VK X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.56 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 0222621395 X-Spam-Score: 0.56 X-Migadu-Scanner: scn0.migadu.com X-TUID: qp5ZUHRjbtHo This avoids reading the configuration file twice. --- lib/open.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index d052f95d..ebf70c15 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -429,8 +429,7 @@ notmuch_database_open_with_config (const char *database_path, if (status) goto DONE; - if (! (notmuch->xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) { - message = strdup ("Out of memory\n"); + if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) { status = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; } @@ -531,12 +530,16 @@ notmuch_database_create_with_config (const char *database_path, goto DONE; } - /* XXX this reads the config file twice, which is a bit wasteful */ - status = notmuch_database_open_with_config (database_path, - NOTMUCH_DATABASE_MODE_READ_WRITE, - config_path, - profile, - ¬much, &message); + if (! (notmuch->xapian_path = talloc_asprintf (notmuch, "%s/%s", notmuch_path, "xapian"))) { + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } + + status = _finish_open (notmuch, + profile, + NOTMUCH_DATABASE_MODE_READ_WRITE, + key_file, + &message); if (status) goto DONE; -- 2.30.0