From 9776399a9d7e03269520989c45c2bbfeb474e233 Mon Sep 17 00:00:00 2001 From: Marvin Humphrey Date: Sun, 8 Feb 2015 21:59:59 -0800 Subject: [PATCH 1/2] Cease using refcount method API. --- core/Lucy/Test/Store/TestRAMDirHandle.c | 4 ++-- core/Lucy/Util/Freezer.c | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/Lucy/Test/Store/TestRAMDirHandle.c b/core/Lucy/Test/Store/TestRAMDirHandle.c index b4e2077ea..22b1dff6c 100644 --- a/core/Lucy/Test/Store/TestRAMDirHandle.c +++ b/core/Lucy/Test/Store/TestRAMDirHandle.c @@ -73,9 +73,9 @@ test_all(TestBatchRunner *runner) { TEST_FALSE(runner, boffo_was_dir, "File correctly identified by Entry_Is_Dir"); - uint32_t refcount = RAMFolder_Get_RefCount(folder); + uint32_t refcount = REFCOUNT_NN(folder); RAMDH_Close(dh); - TEST_INT_EQ(runner, RAMFolder_Get_RefCount(folder), refcount - 1, + TEST_INT_EQ(runner, REFCOUNT_NN(folder), refcount - 1, "Folder reference released by Close()"); DECREF(dh); diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c index 8ad41e5de..b491d5974 100644 --- a/core/Lucy/Util/Freezer.c +++ b/core/Lucy/Util/Freezer.c @@ -139,13 +139,9 @@ Freezer_deserialize(Obj *obj, InStream *instream) { if (Obj_Is_A(obj, INTNUM)) { if (Obj_Is_A(obj, BOOLNUM)) { bool value = !!InStream_Read_U8(instream); - BoolNum *self = (BoolNum*)obj; - if (self && self != CFISH_TRUE && self != CFISH_FALSE) { - Bool_Dec_RefCount_t super_decref - = SUPER_METHOD_PTR(BOOLNUM, CFISH_Bool_Dec_RefCount); - super_decref(self); - } - obj = value ? (Obj*)CFISH_TRUE : (Obj*)CFISH_FALSE; + Obj *result = value ? INCREF(CFISH_TRUE) : INCREF(CFISH_FALSE); + DECREF(obj); + obj = result; } else if (Obj_Is_A(obj, INTEGER32)) { int32_t value = (int32_t)InStream_Read_C32(instream); From 1d77921fb844822d172cdd919e003ac968edc5b9 Mon Sep 17 00:00:00 2001 From: Marvin Humphrey Date: Sun, 8 Feb 2015 22:00:25 -0800 Subject: [PATCH 2/2] Change RawPosting refcounting. Cease overriding refcount manipulation methods. Leak a refcount on purpose so that destructor should never be called. --- core/Lucy/Index/Posting/RawPosting.c | 20 +++----------------- core/Lucy/Index/Posting/RawPosting.cfh | 9 --------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/core/Lucy/Index/Posting/RawPosting.c b/core/Lucy/Index/Posting/RawPosting.c index 4c9a234ac..06e5367c3 100644 --- a/core/Lucy/Index/Posting/RawPosting.c +++ b/core/Lucy/Index/Posting/RawPosting.c @@ -42,6 +42,9 @@ RawPost_new(void *pre_allocated_memory, int32_t doc_id, uint32_t freq, ivars->aux_len = 0; memcpy(&ivars->blob, term_text, term_text_len); + // Leak a refcount on purpose. + INCREF(self); + return self; } @@ -73,23 +76,6 @@ RawPost_Compare_To_IMP(RawPosting *self, Obj *other) { return comparison; } -uint32_t -RawPost_Get_RefCount_IMP(RawPosting* self) { - UNUSED_VAR(self); - return 1; -} - -RawPosting* -RawPost_Inc_RefCount_IMP(RawPosting* self) { - return self; -} - -uint32_t -RawPost_Dec_RefCount_IMP(RawPosting* self) { - UNUSED_VAR(self); - return 1; -} - /***************************************************************************/ RawPostingWriter* diff --git a/core/Lucy/Index/Posting/RawPosting.cfh b/core/Lucy/Index/Posting/RawPosting.cfh index 2fe028673..67ef714ca 100644 --- a/core/Lucy/Index/Posting/RawPosting.cfh +++ b/core/Lucy/Index/Posting/RawPosting.cfh @@ -50,15 +50,6 @@ class Lucy::Index::RawPosting nickname RawPost new(void *pre_allocated_memory, int32_t doc_id, uint32_t freq, const char *term_text, size_t term_text_len); - uint32_t - Get_RefCount(RawPosting* self); - - incremented RawPosting* - Inc_RefCount(RawPosting* self); - - uint32_t - Dec_RefCount(RawPosting* self); - public int32_t Compare_To(RawPosting *self, Obj *other);