From: David Bremner Date: Sun, 27 Sep 2015 12:14:39 +0000 (+2100) Subject: [patch v3.1] lib: move query variable to function scope X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0b1b946a43e878e2b18166f671e8fea4da8a9aa3;p=notmuch-archives.git [patch v3.1] lib: move query variable to function scope --- diff --git a/f7/7fd5b57e72903fa831532cc509a6c6d21e02e3 b/f7/7fd5b57e72903fa831532cc509a6c6d21e02e3 new file mode 100644 index 000000000..d9955ffb8 --- /dev/null +++ b/f7/7fd5b57e72903fa831532cc509a6c6d21e02e3 @@ -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 E80B26DE100C + for ; Sun, 27 Sep 2015 05:15:49 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.11 +X-Spam-Level: +X-Spam-Status: No, score=0.11 tagged_above=-999 required=5 tests=[AWL=0.110] + 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 s19S2FNigiCh for ; + Sun, 27 Sep 2015 05:15:48 -0700 (PDT) +Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224]) + by arlo.cworth.org (Postfix) with ESMTPS id BEFB76DE1003 + for ; Sun, 27 Sep 2015 05:15:47 -0700 (PDT) +Received: from remotemail by gitolite.debian.net with local (Exim 4.80) + (envelope-from ) + id 1ZgArB-0007XR-E3; Sun, 27 Sep 2015 12:15:05 +0000 +Received: (nullmailer pid 15431 invoked by uid 1000); Sun, 27 Sep 2015 + 12:14:46 -0000 +From: David Bremner +To: David Bremner , notmuch@notmuchmail.org +Subject: [patch v3.1] lib: move query variable to function scope +Date: Sun, 27 Sep 2015 09:14:39 -0300 +Message-Id: <1443356079-15388-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.5.3 +In-Reply-To: <1443322213-31075-1-git-send-email-david@tethera.net> +References: <1443322213-31075-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 12:15:50 -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 +