Handle refcounting when clearing SortEx buffer. Now that SortExternal only handles objects rather than addresses, it makes sense to decref objects when emptying out the buffer.
This change is safe for all subclasses and incurs no performance penalty under normal conditions -- unless something goes wrong all buffered items will have already been consumed by the time the buffer-clearing operation is invoked. Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f9889489 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f9889489 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f9889489 Branch: refs/heads/sortex_ptr_only Commit: f9889489ec882cfa9972794fcf9eecec20f04e50 Parents: 8640ab5 Author: Marvin Humphrey <[email protected]> Authored: Tue Jan 8 17:22:23 2013 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Tue Jan 8 17:22:23 2013 -0800 ---------------------------------------------------------------------- core/Lucy/Test/Util/BBSortEx.c | 4 ---- core/Lucy/Util/SortExternal.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/f9889489/core/Lucy/Test/Util/BBSortEx.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Util/BBSortEx.c b/core/Lucy/Test/Util/BBSortEx.c index 0a6fc28..24ed70f 100644 --- a/core/Lucy/Test/Util/BBSortEx.c +++ b/core/Lucy/Test/Util/BBSortEx.c @@ -48,10 +48,6 @@ BBSortEx_destroy(BBSortEx *self) { void BBSortEx_clear_cache(BBSortEx *self) { - Obj **const cache = self->cache; - for (uint32_t i = self->cache_tick, max = self->cache_max; i < max; i++) { - DECREF(cache[i]); - } self->mem_consumed = 0; BBSortEx_Clear_Cache_t super_clear_cache = SUPER_METHOD_PTR(self->vtable, Lucy_BBSortEx_Clear_Cache); http://git-wip-us.apache.org/repos/asf/lucy/blob/f9889489/core/Lucy/Util/SortExternal.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c index a5b885d..ba23c47 100644 --- a/core/Lucy/Util/SortExternal.c +++ b/core/Lucy/Util/SortExternal.c @@ -72,6 +72,10 @@ SortEx_destroy(SortExternal *self) { void SortEx_clear_cache(SortExternal *self) { + Obj **const cache = self->cache; + for (uint32_t i = self->cache_tick, max = self->cache_max; i < max; i++) { + DECREF(cache[i]); + } self->cache_max = 0; self->cache_tick = 0; }
