]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccharset.c
Fix a few memory tracking mistakes.
[fontconfig.git] / src / fccharset.c
index fdff91f810c081280f38b0fd072aa1d21a889b7f..f4042db07dbc2c541213b5578f160456d3023d81 100644 (file)
@@ -55,7 +55,10 @@ FcCharSetDestroy (FcCharSet *fcs)
     int i;
     
     if (fcs->ref == FC_REF_CONSTANT)
+    {
+       FcCacheObjectDereference (fcs);
        return;
+    }
     if (--fcs->ref > 0)
        return;
     for (i = 0; i < fcs->num; i++)
@@ -306,6 +309,8 @@ FcCharSetCopy (FcCharSet *src)
 {
     if (src->ref != FC_REF_CONSTANT)
        src->ref++;
+    else
+       FcCacheObjectReference (src);
     return src;
 }
 
@@ -1059,8 +1064,8 @@ FcCharSetHash (FcCharSet *fcs)
     int                i;
 
     /* hash in leaves */
-    for (i = 0; i < fcs->num * (int) (sizeof (FcCharLeaf *) / sizeof (FcChar32)); i++)
-       hash = ((hash << 1) | (hash >> 31)) ^ (FcChar32)(FcCharSetLeaf(fcs, i)->map);
+    for (i = 0; i < fcs->num; i++)
+       hash = ((hash << 1) | (hash >> 31)) ^ FcCharLeafHash (FcCharSetLeaf(fcs,i));
     /* hash in numbers */
     for (i = 0; i < fcs->num; i++)
        hash = ((hash << 1) | (hash >> 31)) ^ *FcCharSetNumbers(fcs);
@@ -1234,6 +1239,9 @@ FcCharSetFreezerDestroy (FcCharSetFreezer *freezer)
        for (ent = freezer->set_hash_table[i]; ent; ent = next)
        {
            next = ent->next;
+           FcMemFree (FC_MEM_CHARSET, (sizeof (FcCharSetEnt) +
+                                       ent->set.num * sizeof (FcCharLeaf *) +
+                                       ent->set.num * sizeof (FcChar16)));
            free (ent);
        }
     }
@@ -1249,7 +1257,10 @@ FcCharSetFreezerDestroy (FcCharSetFreezer *freezer)
     }
 
     for (i = 0; i < freezer->leaf_block_count; i++)
+    {
        free (freezer->leaf_blocks[i]);
+       FcMemFree (FC_MEM_CHARLEAF, FC_CHAR_LEAF_BLOCK * sizeof (FcCharLeafEnt));
+    }
 
     free (freezer->leaf_blocks);
     free (freezer);
@@ -1353,3 +1364,6 @@ FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs)
     
     return cs_serialized;
 }
+#define __fccharset__
+#include "fcaliastail.h"
+#undef __fccharset__