[Patch v4 1/9] lib: move query variable to function scope
[notmuch-archives.git] / d0 / d46f92d773c8ba5cf0fee53c45ec61cc57adf5
diff --git a/d0/d46f92d773c8ba5cf0fee53c45ec61cc57adf5 b/d0/d46f92d773c8ba5cf0fee53c45ec61cc57adf5
new file mode 100644 (file)
index 0000000..5273f3a
--- /dev/null
@@ -0,0 +1,89 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id AEE056DE0924\r
+ for <notmuch@notmuchmail.org>; Sun, 27 Sep 2015 08:33:54 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.109\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.109 tagged_above=-999 required=5 tests=[AWL=0.109]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 94tnwe03t3R0 for <notmuch@notmuchmail.org>;\r
+ Sun, 27 Sep 2015 08:33:53 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id CDA496DE025E\r
+ for <notmuch@notmuchmail.org>; Sun, 27 Sep 2015 08:33:52 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1ZgDwq-0008Dp-1Q; Sun, 27 Sep 2015 15:33:08 +0000\r
+Received: (nullmailer pid 11929 invoked by uid 1000); Sun, 27 Sep 2015\r
+ 15:32:11 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v4 1/9] lib: move query variable to function scope\r
+Date: Sun, 27 Sep 2015 12:31:55 -0300\r
+Message-Id: <1443367923-11867-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1443367923-11867-1-git-send-email-david@tethera.net>\r
+References: <1443367923-11867-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 27 Sep 2015 15:33:54 -0000\r
+\r
+This is a prelude to deallocating it (if necessary) on the error path.\r
+---\r
+ lib/database.cc | 6 ++++--\r
+ 1 file changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 6d0e5a6..dcfad8c 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -1372,6 +1372,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
+     enum _notmuch_features target_features, new_features;\r
+     notmuch_status_t status;\r
+     notmuch_private_status_t private_status;\r
++    notmuch_query_t *query = NULL;\r
+     unsigned int count = 0, total = 0;\r
\r
+     status = _notmuch_database_ensure_writable (notmuch);\r
+@@ -1408,7 +1409,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
+     if (new_features &\r
+       (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER |\r
+        NOTMUCH_FEATURE_LAST_MOD)) {\r
+-      notmuch_query_t *query = notmuch_query_create (notmuch, "");\r
++      query = notmuch_query_create (notmuch, "");\r
+       total += notmuch_query_count_messages (query);\r
+       notmuch_query_destroy (query);\r
+     }\r
+@@ -1436,11 +1437,12 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
+     if (new_features &\r
+       (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_BOOL_FOLDER |\r
+        NOTMUCH_FEATURE_LAST_MOD)) {\r
+-      notmuch_query_t *query = notmuch_query_create (notmuch, "");\r
+       notmuch_messages_t *messages;\r
+       notmuch_message_t *message;\r
+       char *filename;\r
\r
++      query = notmuch_query_create (notmuch, "");\r
++\r
+       /* XXX: this should use the _st version, but needs an error\r
+          path */\r
+       for (messages = notmuch_query_search_messages (query);\r
+-- \r
+2.5.3\r
+\r