[xml] Centralize FcExpr allocation
To be improved, using a central pool.
This commit is contained in:
parent
5aebb3e299
commit
a96ecbfa20
46
src/fcxml.c
46
src/fcxml.c
|
@ -69,14 +69,23 @@ FcTestDestroy (FcTest *test)
|
||||||
free (test);
|
free (test);
|
||||||
}
|
}
|
||||||
|
|
||||||
FcExpr *
|
static FcExpr *
|
||||||
FcExprCreateInteger (int i)
|
FcExprAlloc (void)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
||||||
|
|
||||||
|
if (e)
|
||||||
|
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
FcExpr *
|
||||||
|
FcExprCreateInteger (int i)
|
||||||
|
{
|
||||||
|
FcExpr *e = FcExprAlloc ();
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpInteger;
|
e->op = FcOpInteger;
|
||||||
e->u.ival = i;
|
e->u.ival = i;
|
||||||
}
|
}
|
||||||
|
@ -86,11 +95,9 @@ FcExprCreateInteger (int i)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateDouble (double d)
|
FcExprCreateDouble (double d)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpDouble;
|
e->op = FcOpDouble;
|
||||||
e->u.dval = d;
|
e->u.dval = d;
|
||||||
}
|
}
|
||||||
|
@ -100,11 +107,9 @@ FcExprCreateDouble (double d)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateString (const FcChar8 *s)
|
FcExprCreateString (const FcChar8 *s)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpString;
|
e->op = FcOpString;
|
||||||
e->u.sval = FcStrCopy (s);
|
e->u.sval = FcStrCopy (s);
|
||||||
}
|
}
|
||||||
|
@ -114,11 +119,9 @@ FcExprCreateString (const FcChar8 *s)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateMatrix (const FcMatrix *m)
|
FcExprCreateMatrix (const FcMatrix *m)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpMatrix;
|
e->op = FcOpMatrix;
|
||||||
e->u.mval = FcMatrixCopy (m);
|
e->u.mval = FcMatrixCopy (m);
|
||||||
}
|
}
|
||||||
|
@ -128,11 +131,9 @@ FcExprCreateMatrix (const FcMatrix *m)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateBool (FcBool b)
|
FcExprCreateBool (FcBool b)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpBool;
|
e->op = FcOpBool;
|
||||||
e->u.bval = b;
|
e->u.bval = b;
|
||||||
}
|
}
|
||||||
|
@ -142,8 +143,7 @@ FcExprCreateBool (FcBool b)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateNil (void)
|
FcExprCreateNil (void)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
||||||
|
@ -155,11 +155,9 @@ FcExprCreateNil (void)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateField (const char *field)
|
FcExprCreateField (const char *field)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpField;
|
e->op = FcOpField;
|
||||||
e->u.object = FcObjectFromName (field);
|
e->u.object = FcObjectFromName (field);
|
||||||
}
|
}
|
||||||
|
@ -169,11 +167,9 @@ FcExprCreateField (const char *field)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateConst (const FcChar8 *constant)
|
FcExprCreateConst (const FcChar8 *constant)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = FcOpConst;
|
e->op = FcOpConst;
|
||||||
e->u.constant = FcStrCopy (constant);
|
e->u.constant = FcStrCopy (constant);
|
||||||
}
|
}
|
||||||
|
@ -183,11 +179,9 @@ FcExprCreateConst (const FcChar8 *constant)
|
||||||
FcExpr *
|
FcExpr *
|
||||||
FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right)
|
FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right)
|
||||||
{
|
{
|
||||||
FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
|
FcExpr *e = FcExprAlloc ();
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
|
|
||||||
e->op = op;
|
e->op = op;
|
||||||
e->u.tree.left = left;
|
e->u.tree.left = left;
|
||||||
e->u.tree.right = right;
|
e->u.tree.right = right;
|
||||||
|
|
Loading…
Reference in New Issue