Was losing local cached dirs in global cache list

This commit is contained in:
Keith Packard 2002-09-26 00:16:23 +00:00
parent ce50587c2b
commit e712133ca7
3 changed files with 17 additions and 14 deletions

View File

@ -448,14 +448,11 @@ FcGlobalCacheDirAdd (FcGlobalCache *cache,
parent = FcGlobalCacheDirGet (cache, i.dir, i.dir_len, FcTrue); parent = FcGlobalCacheDirGet (cache, i.dir, i.dir_len, FcTrue);
if (!parent) if (!parent)
return 0; return 0;
subdir = malloc (sizeof (FcGlobalCacheSubdir) + subdir = malloc (sizeof (FcGlobalCacheSubdir));
strlen ((const char *) i.base) + 1);
if (!subdir) if (!subdir)
return 0; return 0;
FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir) + FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir));
strlen ((const char *) i.base) + 1); subdir->ent = d;
subdir->file = (FcChar8 *) (subdir + 1);
strcpy ((char *) subdir->file, (const char *) i.base);
subdir->next = parent->subdirs; subdir->next = parent->subdirs;
parent->subdirs = subdir; parent->subdirs = subdir;
return &d->info; return &d->info;
@ -480,8 +477,7 @@ FcGlobalCacheDirDestroy (FcGlobalCacheDir *d)
for (s = d->subdirs; s; s = nexts) for (s = d->subdirs; s; s = nexts)
{ {
nexts = s->next; nexts = s->next;
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir) + FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir));
strlen ((char *) s->file) + 1);
free (s); free (s);
} }
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheDir) + d->len + 1); FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheDir) + d->len + 1);
@ -535,12 +531,15 @@ FcGlobalCacheScanDir (FcFontSet *set,
} }
for (subdir = d->subdirs; subdir; subdir = subdir->next) for (subdir = d->subdirs; subdir; subdir = subdir->next)
{ {
FcFilePathInfo info = FcFilePathInfoGet (subdir->ent->info.file);
if (!FcCacheFontSetAdd (set, dirs, dir, dir_len, if (!FcCacheFontSetAdd (set, dirs, dir, dir_len,
subdir->file, FC_FONT_FILE_DIR)) info.base, FC_FONT_FILE_DIR))
{ {
cache->broken = FcTrue; cache->broken = FcTrue;
return FcFalse; return FcFalse;
} }
FcGlobalCacheReferenced (cache, &subdir->ent->info);
} }
FcGlobalCacheReferenced (cache, &d->info); FcGlobalCacheReferenced (cache, &d->info);

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcdir.c,v 1.7 2002/07/28 10:50:59 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcdir.c,v 1.9 2002/08/31 22:17:32 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -117,6 +117,8 @@ FcFileScan (FcFontSet *set,
{ {
isDir = FcTrue; isDir = FcTrue;
ret = FcStrSetAdd (dirs, file); ret = FcStrSetAdd (dirs, file);
if (cache && ret)
FcGlobalCacheUpdate (cache, file, 0, FC_FONT_FILE_DIR);
} }
/* /*
* Update the cache * Update the cache

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.24 2002/08/22 07:36:44 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.27 2002/08/31 22:17:32 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -238,18 +238,20 @@ typedef struct _FcGlobalCacheFile {
FcChar8 *name; FcChar8 *name;
} FcGlobalCacheFile; } FcGlobalCacheFile;
typedef struct _FcGlobalCacheDir FcGlobalCacheDir;
typedef struct _FcGlobalCacheSubdir { typedef struct _FcGlobalCacheSubdir {
struct _FcGlobalCacheSubdir *next; struct _FcGlobalCacheSubdir *next;
FcChar8 *file; FcGlobalCacheDir *ent;
} FcGlobalCacheSubdir; } FcGlobalCacheSubdir;
typedef struct _FcGlobalCacheDir { struct _FcGlobalCacheDir {
struct _FcGlobalCacheDir *next; struct _FcGlobalCacheDir *next;
FcGlobalCacheInfo info; FcGlobalCacheInfo info;
int len; int len;
FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE]; FcGlobalCacheFile *ents[FC_GLOBAL_CACHE_FILE_HASH_SIZE];
FcGlobalCacheSubdir *subdirs; FcGlobalCacheSubdir *subdirs;
} FcGlobalCacheDir; };
typedef struct _FcGlobalCache { typedef struct _FcGlobalCache {
FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE]; FcGlobalCacheDir *ents[FC_GLOBAL_CACHE_DIR_HASH_SIZE];