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