static FcPatternEltPtr
FcPatternEltPtrCreateDynamic (FcPatternElt * e);
+/* If you are trying to duplicate an FcPattern which will be used for
+ * rendering, be aware that (internally) you also have to use
+ * FcPatternTransferFullFname to transfer the associated filename. If
+ * you are copying the font (externally) using FcPatternGetString,
+ * then everything's fine; this caveat only applies if you're copying
+ * the bits individually. */
+
FcPattern *
FcPatternCreate (void)
{
{
int i;
- if (FcPatternFindFullFname (p))
- FcPatternAddFullFname (p, 0);
-
if (p->ref == FC_REF_CONSTANT || --p->ref > 0)
return;
+ if (FcPatternFindFullFname (p))
+ {
+ FcStrFree ((FcChar8 *)FcPatternFindFullFname (p));
+ FcPatternAddFullFname (p, 0);
+ }
+
for (i = 0; i < p->num; i++)
FcValueListDestroy ((FcPatternEltU(p->elts)+i)->values);
FcValueCanonicalize(&FcValueListPtrU(l)->value),
FcTrue))
goto bail1;
-
- if (!strcmp ((char *)FcObjectPtrU((e + i)->object), FC_FILE))
- {
- FcChar8 * s;
- FcPatternGetString (orig, FC_FILE, 0, &s);
- FcPatternAddFullFname (new, FcPatternFindFullFname(orig));
- }
}
+ FcPatternTransferFullFname (new, orig);
return new;
FcStrNewBank (void);
static int
FcStrNeededBytes (const FcChar8 * s);
+static int
+FcStrNeededBytesAlign (void);
static void *
FcStrDistributeBytes (FcCache * metadata, void * block_ptr);
static const FcChar8 *
FcValueListNewBank (void);
static int
FcValueListNeededBytes (FcValueList * vl);
+static int
+FcValueListNeededBytesAlign (void);
static void *
FcValueListDistributeBytes (FcCache * metadata, void *block_ptr);
static FcValueListPtr
return cum + sizeof (FcPattern) + sizeof(FcPatternElt)*p->num;
}
+int
+FcPatternNeededBytesAlign (void)
+{
+ return __alignof__ (FcPattern) + __alignof__ (FcPatternElt) +
+ FcValueListNeededBytesAlign ();
+}
+
static FcBool
FcPatternEnsureBank (int bi)
{
return 0;
fcpattern_ptr = 0;
+ block_ptr = ALIGN(block_ptr, FcPattern);
fcpatterns[bi] = (FcPattern *)block_ptr;
block_ptr = (void *)((char *)block_ptr +
(sizeof (FcPattern) * fcpattern_count));
FcMemAlloc (FC_MEM_PATELT, sizeof (FcPatternElt) * fcpatternelt_count);
fcpatternelt_ptr = 0;
+ block_ptr = ALIGN(block_ptr, FcPatternElt);
fcpatternelts[bi] = (FcPatternElt *)block_ptr;
block_ptr = (void *)((char *)block_ptr +
(sizeof (FcPatternElt) * fcpatternelt_count));
return FcFalse;
FcMemAlloc (FC_MEM_PATTERN, sizeof (FcPattern) * metadata.pattern_count);
+ block_ptr = ALIGN(block_ptr, FcPattern);
fcpatterns[bi] = (FcPattern *)block_ptr;
block_ptr = (void *)((char *)block_ptr +
(sizeof (FcPattern) * metadata.pattern_count));
FcMemAlloc (FC_MEM_PATELT,
sizeof (FcPatternElt) * metadata.patternelt_count);
+ block_ptr = ALIGN(block_ptr, FcPatternElt);
fcpatternelts[bi] = (FcPatternElt *)block_ptr;
block_ptr = (void *)((char *)block_ptr +
(sizeof (FcPatternElt) * metadata.patternelt_count));
return cum;
}
+static int
+FcValueListNeededBytesAlign (void)
+{
+ return FcCharSetNeededBytesAlign() + FcLangSetNeededBytesAlign() +
+ FcStrNeededBytesAlign() + __alignof__ (FcValueList);
+}
+
static FcBool
FcValueListEnsureBank (int bi)
{
FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList) * fcvaluelist_count);
fcvaluelist_ptr = 0;
+ block_ptr = ALIGN(block_ptr, FcValueList);
fcvaluelists[bi] = (FcValueList *)block_ptr;
block_ptr = (void *)((char *)block_ptr +
(sizeof (FcValueList) * fcvaluelist_count));
fcvaluelists[bi][fcvaluelist_ptr] = *pi;
new.bank = bank;
new.u.stat = fcvaluelist_ptr++;
+ fcvaluelists[bi][new.u.stat].value = FcValueCanonicalize (&pi->value);
v = &fcvaluelists[bi][new.u.stat].value;
switch (v->type)
{
FcMemAlloc (FC_MEM_VALLIST,
sizeof (FcValueList) * metadata.valuelist_count);
+ block_ptr = ALIGN(block_ptr, FcValueList);
fcvaluelists[bi] = (FcValueList *)block_ptr;
block_ptr = (void *)((char *)block_ptr +
(sizeof (FcValueList) * metadata.valuelist_count));
b->next = 0;
b->hash = hash;
strcpy ((char *) (b + 1), (char *)s);
+
+ /* Yes, the following line is convoluted. However, it is
+ * incorrect to replace the with a memset, because the C
+ * specification doesn't guarantee that the null pointer is
+ * the same as the zero bit pattern. */
*(char **)((char *) (b + 1) + strlen((char *)s) + 1) = 0;
*p = b;
return strlen((char *)s) + 1;
}
+static int
+FcStrNeededBytesAlign (void)
+{
+ return __alignof__ (char);
+}
+
static FcBool
FcStrEnsureBank (int bi)
{
return 0;
FcMemAlloc (FC_MEM_STRING, sizeof (char) * fcstr_count);
+ block_ptr = ALIGN (block_ptr, FcChar8);
static_strs[bi] = (FcChar8 *)block_ptr;
block_ptr = (void *)((char *)block_ptr + (sizeof (char) * fcstr_count));
metadata->str_count = fcstr_count;
{
FcChar8 * s;
FcPatternGetString (orig, FC_FILE, 0, &s);
- FcPatternAddFullFname (new, FcPatternFindFullFname(orig));
+ FcPatternAddFullFname (new,
+ (char *)FcStrCopy
+ ((FcChar8 *)FcPatternFindFullFname(orig)));
}