summaryrefslogtreecommitdiff
path: root/src/cairo-hash.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2004-11-23 12:53:46 +0000
committerCarl Worth <cworth@cworth.org>2004-11-23 12:53:46 +0000
commit7478ea5051306cf38ed29d9c9faa4c0263f413b8 (patch)
tree3f090401ae2ed72ef59a282f8145de8053f963dd /src/cairo-hash.c
parent78f1206bf8d71d56117fa5dee95b1314f7b1421c (diff)
downloadcairo-7478ea5051306cf38ed29d9c9faa4c0263f413b8.tar.gz
Add note that bug has been fixed. (main): Instrumentation code for testing cache destruction.
Support tests that produce no output, (don't check image if (width,height) == (0,0)). Add #include <assert.h> here rather than in multiple .c files. Add const qualifier to static cache_arrangements table. (_cache_sane_state): Remove refcount assertion as it it false during the cairo_cache_destroy. (_cache_sane_state): #include <assert.h> moved up to cairoint.h (_entry_destroy): Fix bug in assertion (used_memory >= entry->memory), not >. (_cairo_cache_destroy): Fix timing of refcount decrement so that the destroy function actually works.
Diffstat (limited to 'src/cairo-hash.c')
-rw-r--r--src/cairo-hash.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index a33d69a04..fffd888ab 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -43,7 +43,7 @@
* Packard.
*/
-static cairo_cache_arrangement_t cache_arrangements [] = {
+static const cairo_cache_arrangement_t cache_arrangements [] = {
{ 16, 43, 41 },
{ 32, 73, 71 },
{ 64, 151, 149 },
@@ -114,7 +114,6 @@ static cairo_cache_arrangement_t cache_arrangements [] = {
(!((NULL_ENTRY_P((cache),(i))) || (DEAD_ENTRY_P((cache),(i)))))
#ifdef CAIRO_DO_SANITY_CHECKING
-#include <assert.h>
static void
_cache_sane_state (cairo_cache_t *cache)
{
@@ -122,13 +121,14 @@ _cache_sane_state (cairo_cache_t *cache)
assert (cache->entries != NULL);
assert (cache->backend != NULL);
assert (cache->arrangement != NULL);
+/* XXX: This check is broken during destroy
assert (cache->refcount > 0);
+*/
assert (cache->used_memory <= cache->max_memory);
assert (cache->live_entries <= cache->arrangement->size);
}
#else
#define _cache_sane_state(c)
-#define assert(x)
#endif
static void
@@ -140,7 +140,7 @@ _entry_destroy (cairo_cache_t *cache, unsigned long i)
{
cairo_cache_entry_base_t *entry = cache->entries[i];
assert(cache->live_entries > 0);
- assert(cache->used_memory > entry->memory);
+ assert(cache->used_memory >= entry->memory);
cache->live_entries--;
cache->used_memory -= entry->memory;
@@ -230,8 +230,7 @@ _find_exact_live_entry_for (cairo_cache_t *cache,
return _cache_lookup (cache, key, cache->backend->keys_equal);
}
-
-static cairo_cache_arrangement_t *
+static const cairo_cache_arrangement_t *
_find_cache_arrangement (unsigned long proposed_size)
{
unsigned long idx;
@@ -302,7 +301,7 @@ _cairo_cache_init (cairo_cache_t *cache,
const cairo_cache_backend_t *backend,
unsigned long max_memory)
{
- assert(backend != NULL);
+ assert (backend != NULL);
if (cache != NULL){
cache->arrangement = &cache_arrangements[0];
@@ -342,7 +341,7 @@ _cairo_cache_destroy (cairo_cache_t *cache)
_cache_sane_state (cache);
- if (cache->refcount-- > 0)
+ if (--cache->refcount > 0)
return;
for (i = 0; i < cache->arrangement->size; ++i) {