From 6bbdb0f3e091ebc7579d6708beaac6bd0f1892e5 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 25 Apr 2013 17:07:24 +0100 Subject: Fix SNAFU in the store handling. When the store fills up, the existing code throws away items to make room. Due to a silly oversight (not updating the 'size' after each round of evictions) it keeps throwing away repeatedly until it fails. Fix that here. Should make the store more efficient. --- fitz/res_store.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fitz/res_store.c') diff --git a/fitz/res_store.c b/fitz/res_store.c index bfe7eedb..2cb16c7f 100644 --- a/fitz/res_store.c +++ b/fitz/res_store.c @@ -311,7 +311,8 @@ fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_ while (size > store->max) { /* ensure_space may drop, then retake the lock */ - if (ensure_space(ctx, size - store->max) == 0) + int saved = ensure_space(ctx, size - store->max); + if (saved == 0) { /* Failed to free any space. */ /* If we are using the hash table, then we've already @@ -333,6 +334,7 @@ fz_store_item(fz_context *ctx, void *key, void *val_, unsigned int itemsize, fz_ val->refs--; return NULL; } + size -= saved; } } store->size += itemsize; -- cgit v1.2.3