summaryrefslogtreecommitdiff
path: root/otk_c/gccache.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-12-21 12:04:15 +0000
committerDana Jansens <danakj@orodu.net>2002-12-21 12:04:15 +0000
commit187e7db9c039d7369766aeae7dfdf87f191ac446 (patch)
tree6b46655512d45480aef7cc778e05c82c45aad91d /otk_c/gccache.c
parent59b65db2cac9f359dfcff3ab988e70eab053bdb4 (diff)
a color cache to be proud of!
Diffstat (limited to 'otk_c/gccache.c')
-rw-r--r--otk_c/gccache.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/otk_c/gccache.c b/otk_c/gccache.c
index 7d96677c..71232bf4 100644
--- a/otk_c/gccache.c
+++ b/otk_c/gccache.c
@@ -8,7 +8,7 @@
# include <stdlib.h>
#endif
-static OtkGCCache *gccache;
+static OtkGCCache *gccache = NULL;
OtkGCCacheContext *OtkGCCacheContext_New()
{
@@ -81,12 +81,14 @@ OtkGCCacheItem *OtkGCCacheItem_New()
self->count = 0;
self->hits = 0;
self->fault = False;
+
+ return self;
}
void OtkGCCache_Initialize(int screen_count)
{
- int i;
+ unsigned int i;
gccache = malloc(sizeof(OtkGCCache));
@@ -108,7 +110,7 @@ void OtkGCCache_Initialize(int screen_count)
void OtkGCCache_Destroy()
{
- int i;
+ unsigned int i;
for (i = 0; i < gccache->context_count; ++i)
OtkGCCacheContext_Destroy(gccache->contexts[i]);
@@ -126,7 +128,7 @@ OtkGCCacheContext *OtkGCCache_NextContext(int screen)
{
Window hd = OtkDisplay_ScreenInfo(OBDisplay, screen)->root_window;
OtkGCCacheContext *c;
- int i;
+ unsigned int i;
for (i = 0; i < gccache->context_count; ++i) {
c = gccache->contexts[i];
@@ -155,10 +157,10 @@ OtkGCCacheItem *OtkGCCache_Find(OtkColor *color, XFontStruct *font,
int function, int subwindow, int linewidth)
{
const unsigned long pixel = OtkColor_Pixel(color);
- const unsigned int screen = color->screen;
+ const int screen = color->screen;
const int key = color->red ^ color->green ^ color->blue;
int k = (key % gccache->cache_size) * gccache->cache_buckets;
- int i = 0; // loop variable
+ unsigned int i = 0; // loop variable
OtkGCCacheItem *c = gccache->cache[k], *prev = 0;
/*
@@ -219,13 +221,13 @@ void OtkGCCache_Release(OtkGCCacheItem *item)
void OtkGCCache_Purge()
{
- int i;
+ unsigned int i;
for (i = 0; i < gccache->cache_total_size; ++i) {
OtkGCCacheItem *d = gccache->cache[i];
if (d->ctx && d->count == 0) {
- release(d->ctx);
+ OtkGCCache_InternalRelease(d->ctx);
d->ctx = 0;
}
}