/*
- * $RCSId: xc/lib/fontconfig/src/fccharset.c,v 1.18 2002/08/22 07:36:44 keithp Exp $
+ * fontconfig/src/fccharset.c
*
* Copyright © 2001 Keith Packard
*
return fcs;
}
-FcCharSet *
-FcCharSetNew (void);
-
FcCharSet *
FcCharSetNew (void)
{
int i;
if (fcs->ref == FC_REF_CONSTANT)
+ {
+ FcCacheObjectDereference (fcs);
return;
+ }
if (--fcs->ref > 0)
return;
for (i = 0; i < fcs->num; i++)
{
if (src->ref != FC_REF_CONSTANT)
src->ref++;
+ else
+ FcCacheObjectReference (src);
return src;
}
return FcCharSetOperate (a, b, FcCharSetUnionLeaf, FcTrue, FcTrue);
}
+FcCharSet *
+FcCharSetMerge (FcCharSet *a, const FcCharSet *b)
+{
+ FcCharSet *fcs;
+ FcCharSetIter ai, bi;
+
+ if (a == NULL) {
+ fcs = a = FcCharSetCreate ();
+ } else if (a->ref == FC_REF_CONSTANT) {
+ fcs = FcCharSetCreate ();
+ } else
+ fcs = a;
+
+ if (fcs == NULL)
+ return NULL;
+
+ FcCharSetIterStart (a, &ai);
+ FcCharSetIterStart (b, &bi);
+ while (ai.leaf || bi.leaf)
+ {
+ if (ai.ucs4 < bi.ucs4)
+ {
+ if (!FcCharSetAddLeaf (fcs, ai.ucs4, ai.leaf))
+ goto bail;
+
+ FcCharSetIterNext (a, &ai);
+ }
+ else if (bi.ucs4 < ai.ucs4)
+ {
+ if (!FcCharSetAddLeaf (fcs, bi.ucs4, bi.leaf))
+ goto bail;
+
+ FcCharSetIterNext (b, &bi);
+ }
+ else
+ {
+ FcCharLeaf leaf;
+
+ if (FcCharSetUnionLeaf (&leaf, ai.leaf, bi.leaf))
+ {
+ if (!FcCharSetAddLeaf (fcs, ai.ucs4, &leaf))
+ goto bail;
+ }
+
+ FcCharSetIterNext (a, &ai);
+ FcCharSetIterNext (b, &bi);
+ }
+ }
+
+ if (fcs != a)
+ FcCharSetDestroy (a);
+
+ return fcs;
+
+bail:
+ FcCharSetDestroy (fcs);
+
+ if (fcs != a)
+ FcCharSetDestroy (a);
+
+ return NULL;
+}
+
static FcBool
FcCharSetSubtractLeaf (FcCharLeaf *result,
const FcCharLeaf *al,
static FcChar32
FcCharSetPopCount (FcChar32 c1)
{
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ return __builtin_popcount (c1);
+#else
/* hackmem 169 */
FcChar32 c2 = (c1 >> 1) & 033333333333;
c2 = c1 - c2 - ((c2 >> 1) & 033333333333);
return (((c2 + (c2 >> 3)) & 030707070707) % 077);
+#endif
}
FcChar32
/*
* old coverage API, rather hard to use correctly
*/
-FcChar32
-FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result);
FcChar32
FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result)
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);
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);
}
}
}
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);
return cs_serialized;
}
+#define __fccharset__
+#include "fcaliastail.h"
+#undef __fccharset__