[cairo-commit] cairo/src cairo_cache.c, 1.2, 1.3 cairoint.h, 1.72,
1.73
Carl Worth
commit at pdx.freedesktop.org
Tue Nov 23 12:53:49 PST 2004
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv9854/src
Modified Files:
cairo_cache.c cairoint.h
Log Message:
* test/text_cache_crash.c: Add note that bug has been fixed.
(main): Instrumentation code for testing cache destruction.
* test/cairo_test.c (cairo_test): Support tests that produce no
output, (don't check image if (width,height) == (0,0)).
* src/cairoint.h: Add #include <assert.h> here rather than in
multiple .c files.
* src/cairo_cache.c: 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.
Index: cairo_cache.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_cache.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cairo_cache.c 22 Oct 2004 01:40:50 -0000 1.2
+++ cairo_cache.c 23 Nov 2004 20:53:46 -0000 1.3
@@ -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 @@
(!((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 @@
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 @@
{
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 @@
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 @@
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 @@
_cache_sane_state (cache);
- if (cache->refcount-- > 0)
+ if (--cache->refcount > 0)
return;
for (i = 0; i < cache->arrangement->size; ++i) {
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- cairoint.h 22 Oct 2004 01:40:50 -0000 1.72
+++ cairoint.h 23 Nov 2004 20:53:46 -0000 1.73
@@ -49,6 +49,7 @@
#include "config.h"
#endif
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -276,7 +277,6 @@
} cairo_cache_backend_t;
-
/*
* The cairo_cache system makes the following assumptions about
* entries in its cache:
@@ -312,7 +312,7 @@
typedef struct {
unsigned long refcount;
const cairo_cache_backend_t *backend;
- cairo_cache_arrangement_t *arrangement;
+ const cairo_cache_arrangement_t *arrangement;
cairo_cache_entry_base_t **entries;
unsigned long max_memory;
@@ -362,7 +362,7 @@
} cairo_unscaled_font_t;
/*
- * A cairo_font contains a pointer to a cairo_sizeless_font_t and a scale
+ * A cairo_font contains a pointer to a cairo_unscaled_font_t and a scale
* matrix. These are the things the user holds references to.
*/
@@ -372,7 +372,6 @@
cairo_unscaled_font_t *unscaled;
};
-
/* cairo_font.c is responsible for two global caches:
*
* - font entries: [[[base], name, weight, slant], cairo_unscaled_font_t ]
@@ -416,7 +415,6 @@
void *k1,
void *k2);
-
/* the font backend interface */
typedef struct cairo_font_backend {
More information about the cairo-commit
mailing list