Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A1447431FAF for ; Wed, 18 Jul 2012 11:41:05 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8VN2wL5C+E0Z for ; Wed, 18 Jul 2012 11:41:05 -0700 (PDT) Received: from mail.bustany.org (bustany.org [176.31.244.208]) by olra.theworths.org (Postfix) with ESMTP id DB475431FB6 for ; Wed, 18 Jul 2012 11:41:04 -0700 (PDT) Received: from localhost.localdomain (91-158-2-79.elisa-laajakaista.fi [91.158.2.79]) by mail.bustany.org (Postfix) with ESMTPSA id BB9521400C3 for ; Wed, 18 Jul 2012 20:37:08 +0200 (CEST) From: Adrien Bustany 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 Message-Id: <1342636475-16057-5-git-send-email-adrien@bustany.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1342636475-16057-1-git-send-email-adrien@bustany.org> References: <1342636475-16057-1-git-send-email-adrien@bustany.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Wed, 18 Jul 2012 18:41:06 -0000 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_ @@ -1224,6 +1228,7 @@ func (self *Directory) Destroy() { return } C.notmuch_directory_destroy(self.dir) + self.dir = nil } // TODO: wrap notmuch_filenames_ @@ -1242,6 +1247,7 @@ func (self *Filenames) Destroy() { return } C.notmuch_filenames_destroy(self.fnames) + self.fnames = nil } /* EOF */ -- 1.7.7.6