summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-04-25 17:07:24 +0100
committerRobin Watts <robin.watts@artifex.com>2013-04-26 14:42:54 +0100
commit6bbdb0f3e091ebc7579d6708beaac6bd0f1892e5 (patch)
treec363e077182fde75b391c84eff7438c9e695f0b5 /fitz
parentd1a3e6b7b72f54f291f11a50cd5c043984126885 (diff)
downloadmupdf-6bbdb0f3e091ebc7579d6708beaac6bd0f1892e5.tar.xz
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.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/res_store.c4
1 files changed, 3 insertions, 1 deletions
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;