]> git.wh0rd.org Git - fontconfig.git/commitdiff
Don't free strings that have been returned from FcStrStaticName.
authorPatrick Lam <plam@MIT.EDU>
Mon, 5 Dec 2005 16:08:01 +0000 (16:08 +0000)
committerPatrick Lam <plam@MIT.EDU>
Mon, 5 Dec 2005 16:08:01 +0000 (16:08 +0000)
ChangeLog
src/fcpat.c

index d86eda33a9961c7f1ba2e5dd95937306b78280d5..a367294224ebcaf90154889a80fc203a71e0b5c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
        * fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint, main):
 
index 834bb5e2035e9fe5beb4fa24126ce05aeb08c80f..a626ab6b120256bbb094eecaf9381640126f8a86 100644 (file)
@@ -36,6 +36,8 @@ static int fcvaluelist_bank_count = 0, fcvaluelist_ptr, fcvaluelist_count;
 
 static FcPatternEltPtr
 FcPatternEltPtrCreateDynamic (FcPatternElt * e);
+static FcBool
+FcStrHashed (const FcChar8 *name);
 
 static const char *
 FcPatternFindFullFname (const FcPattern *p);
@@ -69,7 +71,8 @@ FcValueDestroy (FcValue v)
 {
     switch (v.type) {
     case FcTypeString:
-       FcStrFree ((FcChar8 *) v.u.s);
+        if (!FcStrHashed (v.u.s))
+            FcStrFree ((FcChar8 *) v.u.s);
        break;
     case FcTypeMatrix:
        FcMatrixFree ((FcMatrix *) v.u.m);
@@ -150,7 +153,8 @@ FcValueListDestroy (FcValueListPtr l)
     {
        switch (FcValueListPtrU(l)->value.type) {
        case FcTypeString:
-           FcStrFree ((FcChar8 *)FcValueListPtrU(l)->value.u.s);
+            if (!FcStrHashed ((FcChar8 *)FcValueListPtrU(l)->value.u.s))
+                FcStrFree ((FcChar8 *)FcValueListPtrU(l)->value.u.s);
            break;
        case FcTypeMatrix:
            FcMatrixFree ((FcMatrix *)FcValueListPtrU(l)->value.u.m);
@@ -1365,6 +1369,19 @@ static struct objectBucket {
     FcChar32           hash;
 } *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 *
 FcStrStaticName (const FcChar8 *name)
 {