unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Adrien Bustany <adrien@bustany.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/7] go: Make Destroy functions safe to call several times
Date: Wed, 18 Jul 2012 21:34:32 +0300	[thread overview]
Message-ID: <1342636475-16057-5-git-send-email-adrien@bustany.org> (raw)
In-Reply-To: <1342636475-16057-1-git-send-email-adrien@bustany.org>

Those methods were already checking if the underlying C object was NULL,
but they were not setting the pointer to NULL after destroying it.
---
 bindings/go/src/notmuch/notmuch.go |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go
index 3f436a0..d8b2739 100644
--- a/bindings/go/src/notmuch/notmuch.go
+++ b/bindings/go/src/notmuch/notmuch.go
@@ -634,6 +634,7 @@ func (self *Query) SearchMessages() *Messages {
 func (self *Query) Destroy() {
 	if self.query != nil {
 		C.notmuch_query_destroy(self.query)
+		self.query = nil
 	}
 }
 
@@ -680,6 +681,7 @@ func (self *Threads) Valid() bool {
 func (self *Threads) Destroy() {
 	if self.threads != nil {
 		C.notmuch_threads_destroy(self.threads)
+		self.threads = nil
 	}
 }
 
@@ -1143,6 +1145,7 @@ func (self *Message) Destroy() {
 		return
 	}
 	C.notmuch_message_destroy(self.message)
+	self.message = nil
 }
 
 /* Is the given 'tags' iterator pointing at a valid tag.
@@ -1214,6 +1217,7 @@ func (self *Tags) Destroy() {
 		return
 	}
 	C.notmuch_tags_destroy(self.tags)
+	self.tags = nil
 }
 
 // TODO: wrap notmuch_directory_<fct>
@@ -1224,6 +1228,7 @@ func (self *Directory) Destroy() {
 		return
 	}
 	C.notmuch_directory_destroy(self.dir)
+	self.dir = nil
 }
 
 // TODO: wrap notmuch_filenames_<fct>
@@ -1242,6 +1247,7 @@ func (self *Filenames) Destroy() {
 		return
 	}
 	C.notmuch_filenames_destroy(self.fnames)
+	self.fnames = nil
 }
 
 /* EOF */
-- 
1.7.7.6

  parent reply	other threads:[~2012-07-18 18:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 18:34 [PATCH 0/7] Various fixes for the Go bindings Adrien Bustany
2012-07-18 18:34 ` [PATCH 1/7] go: Use iota in enum bindings Adrien Bustany
2012-07-18 20:17   ` Austin Clements
2012-07-18 20:36     ` Sebastien Binet
2012-07-18 18:34 ` [PATCH 2/7] go: Add missing MESSAGE_FLAG_EXCLUDED in Flag enum Adrien Bustany
2012-07-18 18:34 ` [PATCH 3/7] go: Allow notmuch objects to be garbage collected Adrien Bustany
2012-07-18 20:40   ` Austin Clements
2012-07-19 18:25     ` Adrien Bustany
2012-07-20  3:23       ` Austin Clements
2012-07-23 22:03         ` Adrien Bustany
2012-08-04 19:28           ` Austin Clements
2012-10-19  3:55   ` Ethan Glasser-Camp
2012-10-25 18:41     ` Adrien Bustany
2012-07-18 18:34 ` Adrien Bustany [this message]
2012-07-18 18:34 ` [PATCH 5/7] go: Partially bind notmuch_database_upgrade Adrien Bustany
2012-07-18 20:41   ` Austin Clements
2012-07-18 18:34 ` [PATCH 6/7] go: Bind notmuch_database_find_message_by_filename Adrien Bustany
2012-07-18 18:34 ` [PATCH 7/7] go: Bind notmuch_thread_t functions Adrien Bustany
2012-07-18 20:50   ` Austin Clements
2012-07-18 20:51 ` [PATCH 0/7] Various fixes for the Go bindings Austin Clements
2012-07-19 18:29   ` Adrien Bustany

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342636475-16057-5-git-send-email-adrien@bustany.org \
    --to=adrien@bustany.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).