summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-05-28 14:39:31 +0300
committerVille Skyttä <ville.skytta@iki.fi>2011-05-28 14:59:19 +0300
commit99093d5ac8dc4307769c324c2dbaf18849ad8706 (patch)
treee9e605c8649c5859da5cf5ada09899b59328e1c7 /cache.h
parent9cacfd2419fe57111c12e8bcb66e5dab9b11d720 (diff)
downloadvdr-plugin-text2skin-99093d5ac8dc4307769c324c2dbaf18849ad8706.tar.gz
vdr-plugin-text2skin-99093d5ac8dc4307769c324c2dbaf18849ad8706.tar.bz2
(Re?)set bitmap cache size when initializing bitmaps.
Without something like this, when built with gcc 4.6, the cache's max size ends up set to 0 (it's initialized before setup is done) and we crash in cache[].
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/cache.h b/cache.h
index b3cc782..f37e693 100644
--- a/cache.h
+++ b/cache.h
@@ -31,6 +31,7 @@ public:
bool Contains(const key_type &Key);
data_type &operator[](const key_type &Key);
uint Count(void) { return mUsage.size(); }
+ void SetMaxItems(uint MaxItems) { mMaxItems = MaxItems; }
};
template<class key_type, class data_type>
@@ -85,7 +86,7 @@ data_type &cxCache<key_type, data_type>::operator[](const key_type &Key)
return it->second;
}
- if (mUsage.size() == mMaxItems) {
+ while (mUsage.size() >= mMaxItems) {
item_iterator it = mItems.find(*mUsage.begin());
DeleteObject(it->first, it->second);
mUsage.erase(mUsage.begin());