diff --git a/src/fccfg.c b/src/fccfg.c index 1069cd2..bc408db 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -1081,7 +1081,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) case FcOpPlus: v.type = FcTypeString; str = FcStrPlus (vl.u.s, vr.u.s); - v.u.s = FcSharedStr (str); + v.u.s = FcStrdup (str); FcStrFree (str); if (!v.u.s) diff --git a/src/fcdefault.c b/src/fcdefault.c index 0069db2..6937994 100644 --- a/src/fcdefault.c +++ b/src/fcdefault.c @@ -92,7 +92,7 @@ retry: if (!lang) { FcStrSet *langs = FcGetDefaultLangs (); - lang = (FcChar8 *) strdup ((const char *) langs->strs[0]); + lang = FcStrdup (langs->strs[0]); FcStrSetDestroy (langs); if (!fc_atomic_ptr_cmpexch (&default_lang, NULL, lang)) { @@ -195,7 +195,7 @@ FcDefaultSubstitute (FcPattern *pattern) * exact matched "en" has higher score than ll-cc. */ v2.type = FcTypeString; - v2.u.s = FcSharedStr ((FcChar8 *)"en-us"); + v2.u.s = FcStrdup ("en-us"); if (FcPatternObjectGet (pattern, FC_FAMILYLANG_OBJECT, 0, &v) == FcResultNoMatch) { FcPatternObjectAdd (pattern, FC_FAMILYLANG_OBJECT, namelang, FcTrue); @@ -211,7 +211,7 @@ FcDefaultSubstitute (FcPattern *pattern) FcPatternObjectAdd (pattern, FC_FULLNAMELANG_OBJECT, namelang, FcTrue); FcPatternObjectAddWithBinding (pattern, FC_FULLNAMELANG_OBJECT, v2, FcValueBindingWeak, FcTrue); } - FcSharedStrFree ((FcChar8 *) v2.u.s); + FcFree (v2.u.s); } #define __fcdefault__ #include "fcaliastail.h" diff --git a/src/fcint.h b/src/fcint.h index 17298f7..9520be3 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -115,6 +115,9 @@ typedef enum _FcValueBinding { FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame } FcValueBinding; +#define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s))) +#define FcFree(s) (free ((FcChar8 *) (s))) + /* * Serialized data structures use only offsets instead of pointers * A low bit of 1 indicates an offset. @@ -969,12 +972,6 @@ FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet FcPrivate FcBool FcPatternAppend (FcPattern *p, FcPattern *s); -FcPrivate const FcChar8 * -FcSharedStr (const FcChar8 *name); - -FcPrivate FcBool -FcSharedStrFree (FcChar8 *name); - FcPrivate FcChar32 FcStringHash (const FcChar8 *s); diff --git a/src/fclist.c b/src/fclist.c index ba68d68..b7ae899 100644 --- a/src/fclist.c +++ b/src/fclist.c @@ -63,14 +63,14 @@ FcObjectSetAdd (FcObjectSet *os, const char *object) low = 0; mid = 0; c = 1; - object = (char *)FcSharedStr ((FcChar8 *)object); + object = strdup (object); while (low <= high) { mid = (low + high) >> 1; c = os->objects[mid] - object; if (c == 0) { - FcSharedStrFree ((FcChar8 *)object); + FcFree (object); return FcTrue; } if (c < 0) @@ -95,7 +95,7 @@ FcObjectSetDestroy (FcObjectSet *os) if (os->objects) { for (i = 0; i < os->nobject; i++) - FcSharedStrFree ((FcChar8 *)os->objects[i]); + FcFree (os->objects[i]); free ((void *) os->objects); } diff --git a/src/fcname.c b/src/fcname.c index 1bfc3b7..2418189 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -279,7 +279,7 @@ FcNameConvert (FcType type, FcChar8 *string) v.u.i = atoi ((char *) string); break; case FcTypeString: - v.u.s = FcSharedStr (string); + v.u.s = FcStrdup (string); if (!v.u.s) v.type = FcTypeVoid; break; diff --git a/src/fcobjs.c b/src/fcobjs.c index 9336068..4a1b0a8 100644 --- a/src/fcobjs.c +++ b/src/fcobjs.c @@ -53,7 +53,7 @@ retry: if (!ot) return NULL; - ot->object.object = strdup (str); + ot->object.object = FcStrdup (str); ot->object.type = -1; ot->id = fc_atomic_int_add (next_id, +1); ot->next = ots; diff --git a/src/fcpat.c b/src/fcpat.c index c3b90d6..b3b155d 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -45,8 +45,7 @@ FcValueDestroy (FcValue v) { switch ((int) v.type) { case FcTypeString: - if (!FcSharedStrFree (v.u.s)) - FcStrFree ((FcChar8 *) v.u.s); + FcFree (v.u.s); break; case FcTypeMatrix: FcMatrixFree ((FcMatrix *) v.u.m); @@ -93,7 +92,7 @@ FcValueSave (FcValue v) { switch ((int) v.type) { case FcTypeString: - v.u.s = FcSharedStr (v.u.s); + v.u.s = FcStrdup (v.u.s); if (!v.u.s) v.type = FcTypeVoid; break; @@ -132,8 +131,7 @@ FcValueListDestroy (FcValueListPtr l) { switch ((int) l->value.type) { case FcTypeString: - if (!FcSharedStrFree ((FcChar8 *)l->value.u.s)) - FcStrFree ((FcChar8 *)l->value.u.s); + FcFree (l->value.u.s); break; case FcTypeMatrix: FcMatrixFree ((FcMatrix *)l->value.u.m); @@ -1147,23 +1145,6 @@ bail0: } -/* We used to have a shared-str pool. Removed to make thread-safety - * work easier. My measurements show that the extra overhead is not - * significant by any means. */ - -FcBool -FcSharedStrFree (FcChar8 *name) -{ - free (name); - return FcTrue; -} - -const FcChar8 * -FcSharedStr (const FcChar8 *name) -{ - return strdup ((const char *) name); -} - FcBool FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat) { diff --git a/src/fcstr.c b/src/fcstr.c index f278022..34093a0 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -38,16 +38,7 @@ FcChar8 * FcStrCopy (const FcChar8 *s) { - int len; - FcChar8 *r; - if (!s) - return 0; - len = strlen ((char *) s) + 1; - r = (FcChar8 *) malloc (len); - if (!r) - return 0; - memcpy (r, s, len); - return r; + return FcStrdup (s); } FcChar8 * diff --git a/src/fcxml.c b/src/fcxml.c index 1963cba..1f068ce 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -99,7 +99,7 @@ FcExprCreateString (FcConfig *config, const FcChar8 *s) if (e) { e->op = FcOpString; - e->u.sval = FcSharedStr (s); + e->u.sval = FcStrdup (s); } return e; } @@ -205,7 +205,7 @@ FcExprCreateConst (FcConfig *config, const FcChar8 *constant) if (e) { e->op = FcOpConst; - e->u.constant = FcSharedStr (constant); + e->u.constant = FcStrdup (constant); } return e; } @@ -234,7 +234,7 @@ FcExprDestroy (FcExpr *e) case FcOpDouble: break; case FcOpString: - FcSharedStrFree (e->u.sval); + FcFree (e->u.sval); break; case FcOpMatrix: FcExprMatrixFree (e->u.mexpr); @@ -252,7 +252,7 @@ FcExprDestroy (FcExpr *e) case FcOpField: break; case FcOpConst: - FcSharedStrFree (e->u.constant); + FcFree (e->u.constant); break; case FcOpAssign: case FcOpAssignReplace: @@ -2478,7 +2478,7 @@ FcPopValue (FcConfigParse *parse) switch ((int) vstack->tag) { case FcVStackString: - value.u.s = FcSharedStr (vstack->u.string); + value.u.s = FcStrdup (vstack->u.string); if (value.u.s) value.type = FcTypeString; break;