/*
- * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.10 2002/05/31 04:42:42 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.13 2002/06/26 22:56:51 keithp Exp $
*
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
*
static int FcCharLeafUsed;
static FcCharLeaf *
-FcNameParseBuildLeaf (FcCharLeaf *leaf)
+FcCharSetFreezeLeaf (FcCharLeaf *leaf)
{
static FcCharLeafEnt *hashTable[FC_CHAR_LEAF_HASH_SIZE];
FcChar32 hash = FcCharLeafHash (leaf);
static int FcCharSetTotalEnts, FcCharSetUsedEnts;
static FcCharSet *
-FcNameParseBuildSet (FcCharSet *fcs)
+FcCharSetFreezeBase (FcCharSet *fcs)
{
static FcCharSetEnt *hashTable[FC_CHAR_SET_HASH_SIZE];
FcChar32 hash = FcCharSetHash (fcs);
ent->set.ref = 0;
ent->set.constant = FcTrue;
ent->set.num = fcs->num;
- ent->set.leaves = (FcCharLeaf **) (ent + 1);
- ent->set.numbers = (FcChar16 *) (ent->set.leaves + fcs->num);
- memcpy (ent->set.leaves, fcs->leaves, fcs->num * sizeof (FcCharLeaf *));
- memcpy (ent->set.numbers, fcs->numbers, fcs->num * sizeof (FcChar16));
+ if (fcs->num)
+ {
+ ent->set.leaves = (FcCharLeaf **) (ent + 1);
+ ent->set.numbers = (FcChar16 *) (ent->set.leaves + fcs->num);
+ memcpy (ent->set.leaves, fcs->leaves, fcs->num * sizeof (FcCharLeaf *));
+ memcpy (ent->set.numbers, fcs->numbers, fcs->num * sizeof (FcChar16));
+ }
+ else
+ {
+ ent->set.leaves = 0;
+ ent->set.numbers = 0;
+ }
ent->hash = hash;
ent->next = *bucket;
return &ent->set;
}
+FcCharSet *
+FcCharSetFreeze (FcCharSet *fcs)
+{
+ FcCharSet *b;
+ FcCharSet *n = 0;
+ FcCharLeaf *l;
+ int i;
+
+ b = FcCharSetCreate ();
+ if (!b)
+ goto bail0;
+ for (i = 0; i < fcs->num; i++)
+ {
+ l = FcCharSetFreezeLeaf (fcs->leaves[i]);
+ if (!l)
+ goto bail1;
+ if (!FcCharSetInsertLeaf (b, fcs->numbers[i] << 8, l))
+ goto bail1;
+ }
+ n = FcCharSetFreezeBase (b);
+bail1:
+ if (b->leaves)
+ free (b->leaves);
+ if (b->numbers)
+ free (b->numbers);
+ free (b);
+bail0:
+ return n;
+}
+
FcCharSet *
FcNameParseCharSet (FcChar8 *string)
{
}
if (bits)
{
- leaf = FcNameParseBuildLeaf (&temp);
+ leaf = FcCharSetFreezeLeaf (&temp);
if (!leaf)
goto bail1;
if (!FcCharSetInsertLeaf (c, ucs4, leaf))
sizeof (FcCharSet) * FcCharSetUsed +
FcCharSetUsedEnts * (sizeof (FcCharLeaf *) + sizeof (FcChar16)));
#endif
- n = FcNameParseBuildSet (c);
+ n = FcCharSetFreezeBase (c);
bail1:
if (c->leaves)
free (c->leaves);