]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccache.c
Insert newly created caches into reference data structure.
[fontconfig.git] / src / fccache.c
index 77a303d77a044e59bedb6a3ba70e0e030115aca5..e289c5dd89bd3f8a400a21fb8edacfa0645d42d2 100644 (file)
@@ -275,9 +275,18 @@ FcCacheInsert (FcCache *cache, struct stat *cache_stat)
     s->cache = cache;
     s->size = cache->size;
     s->ref = 1;
-    s->cache_dev = cache_stat->st_dev;
-    s->cache_ino = cache_stat->st_ino;
-    s->cache_mtime = cache_stat->st_mtime;
+    if (cache_stat)
+    {
+       s->cache_dev = cache_stat->st_dev;
+       s->cache_ino = cache_stat->st_ino;
+       s->cache_mtime = cache_stat->st_mtime;
+    }
+    else
+    {
+       s->cache_dev = 0;
+       s->cache_ino = 0;
+       s->cache_mtime = 0;
+    }
     
     /*
      * Insert into all fcCacheChains
@@ -331,7 +340,6 @@ FcCacheRemove (FcCache *cache)
         update[i] = &next[i];
     }
     s = next[0];
-    assert (s->cache == cache);
     for (i = 0; i < fcCacheMaxLevel && *update[i] == s; i++)
        *update[i] = s->next[i];
     while (fcCacheMaxLevel > 0 && fcCacheChains[fcCacheMaxLevel - 1] == NULL)
@@ -348,7 +356,10 @@ FcCacheFindByStat (struct stat *cache_stat)
        if (s->cache_dev == cache_stat->st_dev &&
            s->cache_ino == cache_stat->st_ino &&
            s->cache_mtime == cache_stat->st_mtime)
+       {
+           s->ref++;
            return s->cache;
+       }
     return NULL;
 }
 
@@ -656,6 +667,8 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, FcStrSet *dirs)
 
     FcSerializeDestroy (serialize);
     
+    FcCacheInsert (cache, NULL);
+
     return cache;
 
 bail2:
@@ -814,11 +827,16 @@ FcCacheCopySet args(const FcCache *c)
     if (!new)
        return NULL;
     for (i = 0; i < old->nfont; i++)
-       if (!FcFontSetAdd (new, FcFontSetFont (old, i)))
+    {
+       FcPattern   *font = FcFontSetFont (old, i);
+       
+       FcPatternReference (font);
+       if (!FcFontSetAdd (new, font))
        {
            FcFontSetDestroy (new);
            return NULL;
        }
+    }
     return new;
 }
 
@@ -1083,3 +1101,6 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16])
     buf[2] += c;
     buf[3] += d;
 }
+#define __fccache__
+#include "fcaliastail.h"
+#undef __fccache__