Destroy the alias and UUID tables when all of caches is unloaded
When a cache contains no fonts, it will be unloaded immediately. Previously the certain alias and UUID entries will be purged at that time though, this doesn't work when the targeted directory has sub-directories. To avoid the unnecessary cache creation with the md5-based naming, try to keep them as far as possible. Although this way seems not perfectly working if the first directory to look up is like that
This commit is contained in:
parent
d7133f4ed7
commit
b01bf646f1
|
@ -88,28 +88,24 @@ FcCacheUuidAdd (FcUuidHashTable *table,
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static void
|
||||||
FcCacheUuidRemove (FcUuidHashTable *table,
|
FcCacheUuidDestroy (FcUuidHashTable *table)
|
||||||
const FcChar8 *file)
|
|
||||||
{
|
{
|
||||||
FcUuidBucket **prev, *bucket;
|
int i;
|
||||||
FcChar32 hash = FcStrHashIgnoreCase (file);
|
|
||||||
|
|
||||||
for (prev = &table->buckets[hash % FC_UUID_HASH_SIZE];
|
for (i = 0; i < FC_UUID_HASH_SIZE; i++)
|
||||||
(bucket = *prev); )
|
|
||||||
{
|
{
|
||||||
if (FcStrCmp (bucket->file, file) == 0)
|
FcUuidBucket *bucket = table->buckets[i], *prev;
|
||||||
{
|
|
||||||
*prev = bucket->next;
|
|
||||||
FcStrFree (bucket->file);
|
|
||||||
free (bucket);
|
|
||||||
|
|
||||||
return FcTrue;
|
while (bucket)
|
||||||
|
{
|
||||||
|
FcStrFree (bucket->file);
|
||||||
|
prev = bucket;
|
||||||
|
bucket = bucket->next;
|
||||||
|
free (prev);
|
||||||
}
|
}
|
||||||
else
|
table->buckets[i] = NULL;
|
||||||
prev = &(bucket->next);
|
|
||||||
}
|
}
|
||||||
return FcFalse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
|
@ -269,29 +265,25 @@ FcCacheAliasAdd (FcAliasHashTable *table,
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static void
|
||||||
FcCacheAliasRemove (FcAliasHashTable *table,
|
FcCacheAliasDestroy (FcAliasHashTable *table)
|
||||||
const FcChar8 *orig)
|
|
||||||
{
|
{
|
||||||
FcAliasBucket **prev, *bucket;
|
int i;
|
||||||
FcChar32 hash = FcStrHashIgnoreCase (orig);
|
|
||||||
|
|
||||||
for (prev = &table->buckets[hash % FC_ALIAS_HASH_SIZE];
|
for (i = 0; i < FC_ALIAS_HASH_SIZE; i++)
|
||||||
(bucket = *prev); )
|
|
||||||
{
|
{
|
||||||
if (FcStrCmp (bucket->orig, orig) == 0)
|
FcAliasBucket *bucket = table->buckets[i], *prev;
|
||||||
|
|
||||||
|
while (bucket)
|
||||||
{
|
{
|
||||||
*prev = bucket->next;
|
prev = bucket;
|
||||||
FcStrFree (bucket->orig);
|
FcStrFree (bucket->orig);
|
||||||
FcStrFree (bucket->alias);
|
FcStrFree (bucket->alias);
|
||||||
free (bucket);
|
bucket = bucket->next;
|
||||||
|
free (prev);
|
||||||
return FcTrue;
|
|
||||||
}
|
}
|
||||||
else
|
table->buckets[i] = NULL;
|
||||||
prev = &(bucket->next);
|
|
||||||
}
|
}
|
||||||
return FcFalse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
|
@ -841,13 +833,12 @@ FcCacheObjectDereference (void *object)
|
||||||
{
|
{
|
||||||
if (FcRefDec (&skip->ref) == 1)
|
if (FcRefDec (&skip->ref) == 1)
|
||||||
{
|
{
|
||||||
const FcChar8 *d = FcDirCacheFindAliasPath (FcCacheDir (skip->cache));
|
|
||||||
|
|
||||||
FcCacheUuidRemove (&uuid_table, FcCacheDir (skip->cache));
|
|
||||||
if (d)
|
|
||||||
FcCacheUuidRemove (&uuid_table, d);
|
|
||||||
FcCacheAliasRemove (&alias_table, FcCacheDir (skip->cache));
|
|
||||||
FcDirCacheDisposeUnlocked (skip->cache);
|
FcDirCacheDisposeUnlocked (skip->cache);
|
||||||
|
if (fcCacheMaxLevel == 0)
|
||||||
|
{
|
||||||
|
FcCacheUuidDestroy (&uuid_table);
|
||||||
|
FcCacheAliasDestroy (&alias_table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlock_cache ();
|
unlock_cache ();
|
||||||
|
|
Loading…
Reference in New Issue