Remove FcSharedStr*
This commit is contained in:
parent
6b14378107
commit
93fb1d4bab
|
@ -1081,7 +1081,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
|
||||||
case FcOpPlus:
|
case FcOpPlus:
|
||||||
v.type = FcTypeString;
|
v.type = FcTypeString;
|
||||||
str = FcStrPlus (vl.u.s, vr.u.s);
|
str = FcStrPlus (vl.u.s, vr.u.s);
|
||||||
v.u.s = FcSharedStr (str);
|
v.u.s = FcStrdup (str);
|
||||||
FcStrFree (str);
|
FcStrFree (str);
|
||||||
|
|
||||||
if (!v.u.s)
|
if (!v.u.s)
|
||||||
|
|
|
@ -92,7 +92,7 @@ retry:
|
||||||
if (!lang)
|
if (!lang)
|
||||||
{
|
{
|
||||||
FcStrSet *langs = FcGetDefaultLangs ();
|
FcStrSet *langs = FcGetDefaultLangs ();
|
||||||
lang = (FcChar8 *) strdup ((const char *) langs->strs[0]);
|
lang = FcStrdup (langs->strs[0]);
|
||||||
FcStrSetDestroy (langs);
|
FcStrSetDestroy (langs);
|
||||||
|
|
||||||
if (!fc_atomic_ptr_cmpexch (&default_lang, NULL, lang)) {
|
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.
|
* exact matched "en" has higher score than ll-cc.
|
||||||
*/
|
*/
|
||||||
v2.type = FcTypeString;
|
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)
|
if (FcPatternObjectGet (pattern, FC_FAMILYLANG_OBJECT, 0, &v) == FcResultNoMatch)
|
||||||
{
|
{
|
||||||
FcPatternObjectAdd (pattern, FC_FAMILYLANG_OBJECT, namelang, FcTrue);
|
FcPatternObjectAdd (pattern, FC_FAMILYLANG_OBJECT, namelang, FcTrue);
|
||||||
|
@ -211,7 +211,7 @@ FcDefaultSubstitute (FcPattern *pattern)
|
||||||
FcPatternObjectAdd (pattern, FC_FULLNAMELANG_OBJECT, namelang, FcTrue);
|
FcPatternObjectAdd (pattern, FC_FULLNAMELANG_OBJECT, namelang, FcTrue);
|
||||||
FcPatternObjectAddWithBinding (pattern, FC_FULLNAMELANG_OBJECT, v2, FcValueBindingWeak, FcTrue);
|
FcPatternObjectAddWithBinding (pattern, FC_FULLNAMELANG_OBJECT, v2, FcValueBindingWeak, FcTrue);
|
||||||
}
|
}
|
||||||
FcSharedStrFree ((FcChar8 *) v2.u.s);
|
FcFree (v2.u.s);
|
||||||
}
|
}
|
||||||
#define __fcdefault__
|
#define __fcdefault__
|
||||||
#include "fcaliastail.h"
|
#include "fcaliastail.h"
|
||||||
|
|
|
@ -115,6 +115,9 @@ typedef enum _FcValueBinding {
|
||||||
FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
|
FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
|
||||||
} FcValueBinding;
|
} FcValueBinding;
|
||||||
|
|
||||||
|
#define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s)))
|
||||||
|
#define FcFree(s) (free ((FcChar8 *) (s)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serialized data structures use only offsets instead of pointers
|
* Serialized data structures use only offsets instead of pointers
|
||||||
* A low bit of 1 indicates an offset.
|
* A low bit of 1 indicates an offset.
|
||||||
|
@ -969,12 +972,6 @@ FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet
|
||||||
FcPrivate FcBool
|
FcPrivate FcBool
|
||||||
FcPatternAppend (FcPattern *p, FcPattern *s);
|
FcPatternAppend (FcPattern *p, FcPattern *s);
|
||||||
|
|
||||||
FcPrivate const FcChar8 *
|
|
||||||
FcSharedStr (const FcChar8 *name);
|
|
||||||
|
|
||||||
FcPrivate FcBool
|
|
||||||
FcSharedStrFree (FcChar8 *name);
|
|
||||||
|
|
||||||
FcPrivate FcChar32
|
FcPrivate FcChar32
|
||||||
FcStringHash (const FcChar8 *s);
|
FcStringHash (const FcChar8 *s);
|
||||||
|
|
||||||
|
|
|
@ -63,14 +63,14 @@ FcObjectSetAdd (FcObjectSet *os, const char *object)
|
||||||
low = 0;
|
low = 0;
|
||||||
mid = 0;
|
mid = 0;
|
||||||
c = 1;
|
c = 1;
|
||||||
object = (char *)FcSharedStr ((FcChar8 *)object);
|
object = strdup (object);
|
||||||
while (low <= high)
|
while (low <= high)
|
||||||
{
|
{
|
||||||
mid = (low + high) >> 1;
|
mid = (low + high) >> 1;
|
||||||
c = os->objects[mid] - object;
|
c = os->objects[mid] - object;
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
{
|
{
|
||||||
FcSharedStrFree ((FcChar8 *)object);
|
FcFree (object);
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
|
@ -95,7 +95,7 @@ FcObjectSetDestroy (FcObjectSet *os)
|
||||||
if (os->objects)
|
if (os->objects)
|
||||||
{
|
{
|
||||||
for (i = 0; i < os->nobject; i++)
|
for (i = 0; i < os->nobject; i++)
|
||||||
FcSharedStrFree ((FcChar8 *)os->objects[i]);
|
FcFree (os->objects[i]);
|
||||||
|
|
||||||
free ((void *) os->objects);
|
free ((void *) os->objects);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ FcNameConvert (FcType type, FcChar8 *string)
|
||||||
v.u.i = atoi ((char *) string);
|
v.u.i = atoi ((char *) string);
|
||||||
break;
|
break;
|
||||||
case FcTypeString:
|
case FcTypeString:
|
||||||
v.u.s = FcSharedStr (string);
|
v.u.s = FcStrdup (string);
|
||||||
if (!v.u.s)
|
if (!v.u.s)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,7 +53,7 @@ retry:
|
||||||
if (!ot)
|
if (!ot)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ot->object.object = strdup (str);
|
ot->object.object = FcStrdup (str);
|
||||||
ot->object.type = -1;
|
ot->object.type = -1;
|
||||||
ot->id = fc_atomic_int_add (next_id, +1);
|
ot->id = fc_atomic_int_add (next_id, +1);
|
||||||
ot->next = ots;
|
ot->next = ots;
|
||||||
|
|
25
src/fcpat.c
25
src/fcpat.c
|
@ -45,8 +45,7 @@ FcValueDestroy (FcValue v)
|
||||||
{
|
{
|
||||||
switch ((int) v.type) {
|
switch ((int) v.type) {
|
||||||
case FcTypeString:
|
case FcTypeString:
|
||||||
if (!FcSharedStrFree (v.u.s))
|
FcFree (v.u.s);
|
||||||
FcStrFree ((FcChar8 *) v.u.s);
|
|
||||||
break;
|
break;
|
||||||
case FcTypeMatrix:
|
case FcTypeMatrix:
|
||||||
FcMatrixFree ((FcMatrix *) v.u.m);
|
FcMatrixFree ((FcMatrix *) v.u.m);
|
||||||
|
@ -93,7 +92,7 @@ FcValueSave (FcValue v)
|
||||||
{
|
{
|
||||||
switch ((int) v.type) {
|
switch ((int) v.type) {
|
||||||
case FcTypeString:
|
case FcTypeString:
|
||||||
v.u.s = FcSharedStr (v.u.s);
|
v.u.s = FcStrdup (v.u.s);
|
||||||
if (!v.u.s)
|
if (!v.u.s)
|
||||||
v.type = FcTypeVoid;
|
v.type = FcTypeVoid;
|
||||||
break;
|
break;
|
||||||
|
@ -132,8 +131,7 @@ FcValueListDestroy (FcValueListPtr l)
|
||||||
{
|
{
|
||||||
switch ((int) l->value.type) {
|
switch ((int) l->value.type) {
|
||||||
case FcTypeString:
|
case FcTypeString:
|
||||||
if (!FcSharedStrFree ((FcChar8 *)l->value.u.s))
|
FcFree (l->value.u.s);
|
||||||
FcStrFree ((FcChar8 *)l->value.u.s);
|
|
||||||
break;
|
break;
|
||||||
case FcTypeMatrix:
|
case FcTypeMatrix:
|
||||||
FcMatrixFree ((FcMatrix *)l->value.u.m);
|
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
|
FcBool
|
||||||
FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat)
|
FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat)
|
||||||
{
|
{
|
||||||
|
|
11
src/fcstr.c
11
src/fcstr.c
|
@ -38,16 +38,7 @@
|
||||||
FcChar8 *
|
FcChar8 *
|
||||||
FcStrCopy (const FcChar8 *s)
|
FcStrCopy (const FcChar8 *s)
|
||||||
{
|
{
|
||||||
int len;
|
return FcStrdup (s);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FcChar8 *
|
FcChar8 *
|
||||||
|
|
10
src/fcxml.c
10
src/fcxml.c
|
@ -99,7 +99,7 @@ FcExprCreateString (FcConfig *config, const FcChar8 *s)
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
e->op = FcOpString;
|
e->op = FcOpString;
|
||||||
e->u.sval = FcSharedStr (s);
|
e->u.sval = FcStrdup (s);
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ FcExprCreateConst (FcConfig *config, const FcChar8 *constant)
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
e->op = FcOpConst;
|
e->op = FcOpConst;
|
||||||
e->u.constant = FcSharedStr (constant);
|
e->u.constant = FcStrdup (constant);
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ FcExprDestroy (FcExpr *e)
|
||||||
case FcOpDouble:
|
case FcOpDouble:
|
||||||
break;
|
break;
|
||||||
case FcOpString:
|
case FcOpString:
|
||||||
FcSharedStrFree (e->u.sval);
|
FcFree (e->u.sval);
|
||||||
break;
|
break;
|
||||||
case FcOpMatrix:
|
case FcOpMatrix:
|
||||||
FcExprMatrixFree (e->u.mexpr);
|
FcExprMatrixFree (e->u.mexpr);
|
||||||
|
@ -252,7 +252,7 @@ FcExprDestroy (FcExpr *e)
|
||||||
case FcOpField:
|
case FcOpField:
|
||||||
break;
|
break;
|
||||||
case FcOpConst:
|
case FcOpConst:
|
||||||
FcSharedStrFree (e->u.constant);
|
FcFree (e->u.constant);
|
||||||
break;
|
break;
|
||||||
case FcOpAssign:
|
case FcOpAssign:
|
||||||
case FcOpAssignReplace:
|
case FcOpAssignReplace:
|
||||||
|
@ -2478,7 +2478,7 @@ FcPopValue (FcConfigParse *parse)
|
||||||
|
|
||||||
switch ((int) vstack->tag) {
|
switch ((int) vstack->tag) {
|
||||||
case FcVStackString:
|
case FcVStackString:
|
||||||
value.u.s = FcSharedStr (vstack->u.string);
|
value.u.s = FcStrdup (vstack->u.string);
|
||||||
if (value.u.s)
|
if (value.u.s)
|
||||||
value.type = FcTypeString;
|
value.type = FcTypeString;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue