[PATCH 4/7] go: Make Destroy functions safe to call several times
authorAdrien Bustany <adrien@bustany.org>
Wed, 18 Jul 2012 18:34:32 +0000 (21:34 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:22 +0000 (09:48 -0800)
1c/d233afee4be1fc1adbdf1e52a7564981dfe42d [new file with mode: 0644]

diff --git a/1c/d233afee4be1fc1adbdf1e52a7564981dfe42d b/1c/d233afee4be1fc1adbdf1e52a7564981dfe42d
new file mode 100644 (file)
index 0000000..a51ec4e
--- /dev/null
@@ -0,0 +1,106 @@
+Return-Path: <adrien@bustany.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id A1447431FAF\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Jul 2012 11:41:05 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 8VN2wL5C+E0Z for <notmuch@notmuchmail.org>;\r
+       Wed, 18 Jul 2012 11:41:05 -0700 (PDT)\r
+Received: from mail.bustany.org (bustany.org [176.31.244.208])\r
+       by olra.theworths.org (Postfix) with ESMTP id DB475431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Jul 2012 11:41:04 -0700 (PDT)\r
+Received: from localhost.localdomain (91-158-2-79.elisa-laajakaista.fi\r
+       [91.158.2.79])\r
+       by mail.bustany.org (Postfix) with ESMTPSA id BB9521400C3\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Jul 2012 20:37:08 +0200 (CEST)\r
+From: Adrien Bustany <adrien@bustany.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/7] go: Make Destroy functions safe to call several times\r
+Date: Wed, 18 Jul 2012 21:34:32 +0300\r
+Message-Id: <1342636475-16057-5-git-send-email-adrien@bustany.org>\r
+X-Mailer: git-send-email 1.7.7.6\r
+In-Reply-To: <1342636475-16057-1-git-send-email-adrien@bustany.org>\r
+References: <1342636475-16057-1-git-send-email-adrien@bustany.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Wed, 18 Jul 2012 18:41:06 -0000\r
+\r
+Those methods were already checking if the underlying C object was NULL,\r
+but they were not setting the pointer to NULL after destroying it.\r
+---\r
+ bindings/go/src/notmuch/notmuch.go |    6 ++++++\r
+ 1 files changed, 6 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go\r
+index 3f436a0..d8b2739 100644\r
+--- a/bindings/go/src/notmuch/notmuch.go\r
++++ b/bindings/go/src/notmuch/notmuch.go\r
+@@ -634,6 +634,7 @@ func (self *Query) SearchMessages() *Messages {\r
+ func (self *Query) Destroy() {\r
+       if self.query != nil {\r
+               C.notmuch_query_destroy(self.query)\r
++              self.query = nil\r
+       }\r
+ }\r
+ \r
+@@ -680,6 +681,7 @@ func (self *Threads) Valid() bool {\r
+ func (self *Threads) Destroy() {\r
+       if self.threads != nil {\r
+               C.notmuch_threads_destroy(self.threads)\r
++              self.threads = nil\r
+       }\r
+ }\r
+ \r
+@@ -1143,6 +1145,7 @@ func (self *Message) Destroy() {\r
+               return\r
+       }\r
+       C.notmuch_message_destroy(self.message)\r
++      self.message = nil\r
+ }\r
+ \r
+ /* Is the given 'tags' iterator pointing at a valid tag.\r
+@@ -1214,6 +1217,7 @@ func (self *Tags) Destroy() {\r
+               return\r
+       }\r
+       C.notmuch_tags_destroy(self.tags)\r
++      self.tags = nil\r
+ }\r
+ \r
+ // TODO: wrap notmuch_directory_<fct>\r
+@@ -1224,6 +1228,7 @@ func (self *Directory) Destroy() {\r
+               return\r
+       }\r
+       C.notmuch_directory_destroy(self.dir)\r
++      self.dir = nil\r
+ }\r
+ \r
+ // TODO: wrap notmuch_filenames_<fct>\r
+@@ -1242,6 +1247,7 @@ func (self *Filenames) Destroy() {\r
+               return\r
+       }\r
+       C.notmuch_filenames_destroy(self.fnames)\r
++      self.fnames = nil\r
+ }\r
+ \r
+ /* EOF */\r
+-- \r
+1.7.7.6\r
+\r