diff options
author | Alexander Larsson <alexl@redhat.com> | 2018-05-23 15:15:33 +0200 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2018-05-25 14:42:52 +0900 |
commit | c42402d0b8ada2472924619fc197a0394fbcd62c (patch) | |
tree | 8b5ca3dbb77f250751845914a87dac67d48cba9c /src/fclist.c | |
parent | a63b9c622e240ec0d8f9d83d286db1b55849f374 (diff) | |
download | fontconfig-c42402d0b8ada2472924619fc197a0394fbcd62c.tar.gz |
Cache: Rewrite relocated paths in earlier
This changes the rewriting of the FC_FILE values for relocated caches to an earlier stage
while reading the cache. This is better, because it means all APIs will report the
rewritten paths, not just the once that use the list apis.
We do this by detecting the relocated case and duplicating the FcPattern and FcPatternElm
in an cache allocation (which will die with the cache) and then reusing the FcValueLists
from the cache.
This means that in the rewritten case we will use some more memory, but not the full
size of the cache. In a test here I had 800k of relocated caches, but ~200k of wasted
on duplicating the objects.
This should fix https://bugs.freedesktop.org/show_bug.cgi?id=106618
Diffstat (limited to 'src/fclist.c')
-rw-r--r-- | src/fclist.c | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/fclist.c b/src/fclist.c index 5f92a72..d7e8fc0 100644 --- a/src/fclist.c +++ b/src/fclist.c @@ -448,41 +448,6 @@ FcListAppend (FcListHashTable *table, e = FcPatternObjectFindElt (font, FcObjectFromName (os->objects[o])); if (e) { - if (FcRefIsConst (&font->ref) && !strcmp (os->objects[o], FC_FILE)) - { - FcChar8 *dir, *alias; - FcConfig *config = FcConfigGetCurrent (); /* FIXME: this may need to be exported as API? */ - - for (v = FcPatternEltValues (e); v->value.type != FcTypeString; v = FcValueListNext (v)); - if (!v) - goto bail2; - dir = FcStrDirname (FcValueString (&v->value)); - if (FcHashTableFind (config->alias_table, dir, (void **) &alias)) - { - FcChar8 *base = FcStrBasename (FcValueString (&v->value)); - FcChar8 *s = FcStrBuildFilename (alias, base, NULL); - FcValue vv; - - FcStrFree (alias); - FcStrFree (base); - vv.type = FcTypeString; - vv.u.s = s; - if (!FcPatternAdd (bucket->pattern, - os->objects[o], - FcValueCanonicalize (&vv), - FcTrue)) - { - FcStrFree (s); - FcStrFree (dir); - goto bail2; - } - FcStrFree (s); - FcStrFree (dir); - goto bail3; - } - else - FcStrFree (dir); - } for (v = FcPatternEltValues(e), idx = 0; v; v = FcValueListNext(v), ++idx) { @@ -491,7 +456,6 @@ FcListAppend (FcListHashTable *table, FcValueCanonicalize(&v->value), defidx != idx)) goto bail2; } - bail3:; } } *prev = bucket; |