Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA3451126E for ; Fri, 1 Aug 2014 09:06:14 +0000 (UTC) Received: (qmail 98313 invoked by uid 500); 1 Aug 2014 09:06:14 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 98185 invoked by uid 500); 1 Aug 2014 09:06:14 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 98011 invoked by uid 99); 1 Aug 2014 09:06:14 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Aug 2014 09:06:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5BA469BCA73; Fri, 1 Aug 2014 09:06:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Fri, 01 Aug 2014 09:06:18 -0000 Message-Id: <97b4633bd63249fc8a52bbf129a65cd8@git.apache.org> In-Reply-To: <6f91da64e6eb4513b2b102401de89f83@git.apache.org> References: <6f91da64e6eb4513b2b102401de89f83@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [5/8] git commit: Fix resource destructors Fix resource destructors Apparently the resource name is quite important. The old code was attempting to free all hashes with the iterator destructor which also had a bug that masked the underlying issue. This fixes the wrong destructor issue as well as the iterator destructor bug. Project: http://git-wip-us.apache.org/repos/asf/couchdb-khash/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-khash/commit/f87d8bc7 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-khash/tree/f87d8bc7 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-khash/diff/f87d8bc7 Branch: refs/heads/windsor-merge Commit: f87d8bc73221f8e6c94761e9486b4fcbfd395e25 Parents: 36cccf3 Author: Paul J. Davis Authored: Fri Aug 16 11:14:44 2013 -0500 Committer: Robert Newson Committed: Wed Jul 30 17:16:33 2014 +0100 ---------------------------------------------------------------------- c_src/khash.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-khash/blob/f87d8bc7/c_src/khash.c ---------------------------------------------------------------------- diff --git a/c_src/khash.c b/c_src/khash.c index 038c81c..d206f5e 100644 --- a/c_src/khash.c +++ b/c_src/khash.c @@ -493,7 +493,7 @@ static void khash_iter_free(ErlNifEnv* env, void* obj) { khash_iter_t* iter = (khash_iter_t*) obj; - enif_release_resource(iter); + enif_release_resource(iter->khash); } @@ -538,7 +538,6 @@ khash_iter_next(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info) { - const char* mod = "khash"; int flags = ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER; ErlNifResourceType* res; @@ -547,13 +546,15 @@ load(ErlNifEnv* env, void** priv, ERL_NIF_TERM info) return 1; } - res = enif_open_resource_type(env, mod, "", khash_free, flags, NULL); + res = enif_open_resource_type( + env, NULL, "khash", khash_free, flags, NULL); if(res == NULL) { return 1; } new_priv->res_hash = res; - res = enif_open_resource_type(env, mod, "", khash_iter_free, flags, NULL); + res = enif_open_resource_type( + env, NULL, "khash_iter", khash_iter_free, flags, NULL); if(res == NULL) { return 1; }