* PERFORMANCE OF THIS SOFTWARE.
*/
-#include <stdlib.h>
#include "fcint.h"
+#include <stdlib.h>
/* #define CHECK */
int bi = FcCacheBankToIndexMTF (FC_BANK_LANGS);
FcCharSetEnsureBank (bi);
charsets[bi] = 0;
- numbers[bi] = (FcChar16 *)&langBankNumbers;
- leaves[bi] = (FcCharLeaf *)&langBankLeaves;
- leaf_idx[bi] = (int *)&langBankLeafIdx;
+ numbers[bi] = (FcChar16 *)langBankNumbers;
+ leaves[bi] = (FcCharLeaf *)langBankLeaves;
+ leaf_idx[bi] = (int *)langBankLeafIdx;
}
FcCharSet *
return FcFalse;
if (fcs->bank != FC_BANK_DYNAMIC)
{
+ /* convert to dynamic */
int i;
leaves = malloc ((fcs->num + 1) * sizeof (FcCharLeaf *));
FcMemAlloc (FC_MEM_CHARSET, (fcs->num + 1) * sizeof (FcCharLeaf *));
numbers = malloc ((fcs->num + 1) * sizeof (FcChar16));
if (!numbers)
+ {
+ free (leaves);
return FcFalse;
+ }
FcMemAlloc (FC_MEM_CHARSET, (fcs->num + 1) * sizeof (FcChar16));
for (i = 0; i < fcs->num; i++)
leaves[i] = FcCharSetGetLeaf(fcs, i);
memcpy (numbers, FcCharSetGetNumbers(fcs),
fcs->num * sizeof (FcChar16));
+
+ fcs->bank = FC_BANK_DYNAMIC;
+ fcs->u.dyn.leaves = leaves;
+ fcs->u.dyn.numbers = numbers;
}
else
{
int i = 256/32;
if (ai.ucs4 == bi.ucs4)
{
- FcChar32 *bm = bi.leaf->map;;
+ FcChar32 *bm = bi.leaf->map;
while (i--)
count += FcCharSetPopCount (*am++ & ~*bm++);
}
{
/* yes, there's redundancy */
charset_count++;
- charset_leaf_idx_count++;
+ charset_leaf_idx_count += c->num;
charset_leaf_count += c->num;
charset_numbers_count += c->num;
return sizeof (FcCharSet) +
- sizeof (int) + /* leaf_idx */
+ sizeof (int) * c->num + /* leaf_idx */
sizeof (FcCharLeaf) * c->num + /* leaf */
sizeof (FcChar16) * c->num; /* number */
}
int
FcCharSetNeededBytesAlign (void)
{
- return __alignof__ (FcCharSet) + __alignof__ (int) +
- __alignof__ (FcCharLeaf) + __alignof__ (FcChar16);
+ return fc_alignof (FcCharSet) + fc_alignof (int) +
+ fc_alignof (FcCharLeaf) + fc_alignof (FcChar16);
}
static FcBool
charsets[bi][charset_ptr++] = new;
- leaf_idx[bi][charset_leaf_idx_ptr++] = charset_leaf_ptr;
for (i = 0; i < c->num; i++)
{
+ leaf_idx[bi][charset_leaf_idx_ptr++] = charset_leaf_ptr;
memcpy (&leaves[bi][charset_leaf_ptr++],
c->u.dyn.leaves[i], sizeof(FcCharLeaf));
numbers[bi][charset_numbers_ptr++] = c->u.dyn.numbers[i];
return c->u.dyn.leaves[i];
bi = FcCacheBankToIndex(c->bank);
- return &leaves[bi][leaf_idx[bi][c->u.stat.leafidx_offset]+i];
+ return &leaves[bi][leaf_idx[bi][c->u.stat.leafidx_offset+i]];
}
FcChar16 *