]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcdir.c
Overhaul the serialization system to create one mmapable file per directory
[fontconfig.git] / src / fcdir.c
index 8f7738d2dbe2dcbf5e516a4dab677df7cb3ddce6..4f69f228bc0688fb98fb65df81b13d3a597f3fb1 100644 (file)
@@ -45,13 +45,15 @@ FcFileScanConfig (FcFontSet *set,
                  FcConfig      *config)
 {
     int                        id;
+#if 0
     FcChar8            *name;
+    FcGlobalCacheFile  *cache_file;
+    FcGlobalCacheDir   *cache_dir;
+#endif
     FcPattern          *font;
     FcBool             ret = FcTrue;
     FcBool             isDir;
     int                        count = 0;
-    FcGlobalCacheFile  *cache_file;
-    FcGlobalCacheDir   *cache_dir;
     FcBool             need_scan;
     
     if (config && !FcConfigAcceptFilename (config, file))
@@ -64,6 +66,7 @@ FcFileScanConfig (FcFontSet   *set,
     {
        need_scan = FcTrue;
        font = 0;
+#if 0
        /*
         * Check the cache
         */
@@ -104,6 +107,7 @@ FcFileScanConfig (FcFontSet *set,
                }
            }
        }
+#endif
        /*
         * Nothing in the cache, scan the file
         */
@@ -123,6 +127,7 @@ FcFileScanConfig (FcFontSet *set,
                isDir = FcTrue;
                ret = FcStrSetAdd (dirs, file);
            }
+#if 0
            /*
             * Update the cache
             */
@@ -137,6 +142,7 @@ FcFileScanConfig (FcFontSet *set,
                    FcStrFree (unparse);
                }
            }
+#endif
        }
        /*
         * Add the font
@@ -150,6 +156,8 @@ FcFileScanConfig (FcFontSet *set,
                ret = FcFalse;
            }
        }
+       else if (font)
+           FcPatternDestroy (font);
        id++;
     } while (font && ret && id < count);
     return ret;
@@ -191,6 +199,7 @@ FcDirScanConfig (FcFontSet  *set,
 
     if (!force)
     {
+#if 0
        /*
         * Check fonts.cache-<version> file
         */
@@ -206,6 +215,7 @@ FcDirScanConfig (FcFontSet  *set,
         */
        if (cache && FcGlobalCacheScanDir (set, dirs, cache, dir, config))
            return FcTrue;
+#endif
     }
     
     /* freed below */
@@ -244,8 +254,10 @@ FcDirScanConfig (FcFontSet *set,
      * Now that the directory has been scanned,
      * add the cache entry 
      */
+#if 0
     if (ret && cache)
        FcGlobalCacheUpdate (cache, dir, 0, 0);
+#endif
        
     return ret;
 }
@@ -262,7 +274,17 @@ FcDirScan (FcFontSet           *set,
 }
 
 FcBool
-FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
+FcDirSave (FcFontSet *set, const FcChar8 *dir)
 {
-    return FcDirCacheWriteDir (set, dirs, dir);
+    static int rand_state = 0;
+    int bank;
+
+    if (!rand_state) 
+       rand_state = time(0L);
+    bank = rand_r(&rand_state);
+
+    while (FcCacheHaveBank(bank))
+       bank = rand_r(&rand_state);
+
+    return FcDirCacheWrite (bank, set, dir);
 }