Don't free strings that have been returned from FcStrStaticName.

This commit is contained in:
Patrick Lam 2005-12-05 16:08:01 +00:00
parent 6059daeddb
commit 9ede93f1dc
2 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2005-12-05 Patrick Lam <plam@mit.edu>
* src/fcpat.c (FcValueDestroy, FcValueListDestroy, FcStrHashed):
Don't free strings that have been returned from FcStrStaticName.
2005-12-01 Patrick Lam <plam@mit.edu> 2005-12-01 Patrick Lam <plam@mit.edu>
* fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint, main): * fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint, main):

View File

@ -36,6 +36,8 @@ static int fcvaluelist_bank_count = 0, fcvaluelist_ptr, fcvaluelist_count;
static FcPatternEltPtr static FcPatternEltPtr
FcPatternEltPtrCreateDynamic (FcPatternElt * e); FcPatternEltPtrCreateDynamic (FcPatternElt * e);
static FcBool
FcStrHashed (const FcChar8 *name);
static const char * static const char *
FcPatternFindFullFname (const FcPattern *p); FcPatternFindFullFname (const FcPattern *p);
@ -69,6 +71,7 @@ FcValueDestroy (FcValue v)
{ {
switch (v.type) { switch (v.type) {
case FcTypeString: case FcTypeString:
if (!FcStrHashed (v.u.s))
FcStrFree ((FcChar8 *) v.u.s); FcStrFree ((FcChar8 *) v.u.s);
break; break;
case FcTypeMatrix: case FcTypeMatrix:
@ -150,6 +153,7 @@ FcValueListDestroy (FcValueListPtr l)
{ {
switch (FcValueListPtrU(l)->value.type) { switch (FcValueListPtrU(l)->value.type) {
case FcTypeString: case FcTypeString:
if (!FcStrHashed ((FcChar8 *)FcValueListPtrU(l)->value.u.s))
FcStrFree ((FcChar8 *)FcValueListPtrU(l)->value.u.s); FcStrFree ((FcChar8 *)FcValueListPtrU(l)->value.u.s);
break; break;
case FcTypeMatrix: case FcTypeMatrix:
@ -1365,6 +1369,19 @@ static struct objectBucket {
FcChar32 hash; FcChar32 hash;
} *FcObjectBuckets[OBJECT_HASH_SIZE]; } *FcObjectBuckets[OBJECT_HASH_SIZE];
static FcBool
FcStrHashed (const FcChar8 *name)
{
FcChar32 hash = FcStringHash (name);
struct objectBucket **p;
struct objectBucket *b;
for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
if (b->hash == hash && !strcmp ((char *)name, (char *) (b + 1)))
return FcTrue;
return FcFalse;
}
const FcChar8 * const FcChar8 *
FcStrStaticName (const FcChar8 *name) FcStrStaticName (const FcChar8 *name)
{ {