config->rescanTime = time(0);
config->rescanInterval = 30;
+ config->expr_pool = NULL;
+
config->ref = 1;
return config;
}
}
+FcExpr *
+FcConfigAllocExpr (FcConfig *config)
+{
+ if (!config->expr_pool || config->expr_pool->next == config->expr_pool->end)
+ {
+ FcExprPage *new_page;
+
+ new_page = malloc (sizeof (FcExprPage));
+ if (!new_page)
+ return 0;
+ FcMemAlloc (FC_MEM_EXPR, sizeof (FcExprPage));
+
+ new_page->next_page = config->expr_pool;
+ new_page->next = new_page->exprs;
+ config->expr_pool = new_page;
+ }
+
+ return config->expr_pool->next++;
+}
+
FcConfig *
FcConfigReference (FcConfig *config)
{
FcConfigDestroy (FcConfig *config)
{
FcSetName set;
+ FcExprPage *page;
if (--config->ref > 0)
return;
if (config->fonts[set])
FcFontSetDestroy (config->fonts[set]);
+ page = config->expr_pool;
+ while (page)
+ {
+ FcExprPage *next = page->next_page;
+ FcMemFree (FC_MEM_EXPR, sizeof (FcExprPage));
+ free (page);
+ page = next;
+ }
+
free (config);
FcMemFree (FC_MEM_CONFIG, sizeof (FcConfig));
}
}
static FcExpr *
-FcExprAlloc (void)
+FcExprCreateInteger (FcConfig *config, int i)
{
- FcExpr *e = (FcExpr *) malloc (sizeof (FcExpr));
-
- if (e)
- FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
-
- return e;
-}
-
-static FcExpr *
-FcExprCreateInteger (int i)
-{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpInteger;
}
static FcExpr *
-FcExprCreateDouble (double d)
+FcExprCreateDouble (FcConfig *config, double d)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpDouble;
}
static FcExpr *
-FcExprCreateString (const FcChar8 *s)
+FcExprCreateString (FcConfig *config, const FcChar8 *s)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpString;
}
static FcExpr *
-FcExprCreateMatrix (const FcMatrix *m)
+FcExprCreateMatrix (FcConfig *config, const FcMatrix *m)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpMatrix;
}
static FcExpr *
-FcExprCreateBool (FcBool b)
+FcExprCreateBool (FcConfig *config, FcBool b)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpBool;
}
static FcExpr *
-FcExprCreateNil (void)
+FcExprCreateNil (FcConfig *config)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
}
static FcExpr *
-FcExprCreateField (const char *field)
+FcExprCreateField (FcConfig *config, const char *field)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpField;
}
static FcExpr *
-FcExprCreateConst (const FcChar8 *constant)
+FcExprCreateConst (FcConfig *config, const FcChar8 *constant)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = FcOpConst;
}
static FcExpr *
-FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right)
+FcExprCreateOp (FcConfig *config, FcExpr *left, FcOp op, FcExpr *right)
{
- FcExpr *e = FcExprAlloc ();
+ FcExpr *e = FcConfigAllocExpr (config);
if (e)
{
e->op = op;
case FcOpInvalid:
break;
}
- FcMemFree (FC_MEM_EXPR, sizeof (FcExpr));
- free (e);
+
+ e->op = FcOpNil;
}
void
FcVStackPopAndDestroy (parse);
if (expr)
{
- new = FcExprCreateOp (left, FcOpComma, expr);
+ new = FcExprCreateOp (parse->config, left, FcOpComma, expr);
if (!new)
{
FcConfigMessage (parse, FcSevereError, "out of memory");
FcConfigMessage (parse, FcSevereError, "out of memory");
return;
}
- expr = FcExprCreateString (s);
+ expr = FcExprCreateString (parse->config, s);
FcStrBufDestroy (&parse->pstack->str);
if (expr)
FcVStackPushExpr (parse, FcVStackFamily, expr);
case FcVStackFamily:
if (family)
{
- new = FcExprCreateOp (vstack->u.expr, FcOpComma, family);
+ new = FcExprCreateOp (parse->config, vstack->u.expr, FcOpComma, family);
if (!new)
FcConfigMessage (parse, FcSevereError, "out of memory");
else
break;
case FcVStackString:
case FcVStackFamily:
- expr = FcExprCreateString (vstack->u.string);
+ expr = FcExprCreateString (parse->config, vstack->u.string);
break;
case FcVStackField:
- expr = FcExprCreateField ((char *) vstack->u.string);
+ expr = FcExprCreateField (parse->config, (char *) vstack->u.string);
break;
case FcVStackConstant:
- expr = FcExprCreateConst (vstack->u.string);
+ expr = FcExprCreateConst (parse->config, vstack->u.string);
break;
case FcVStackGlob:
/* XXX: What's the correct action here? (CDW) */
vstack->tag = FcVStackNone;
break;
case FcVStackInteger:
- expr = FcExprCreateInteger (vstack->u.integer);
+ expr = FcExprCreateInteger (parse->config, vstack->u.integer);
break;
case FcVStackDouble:
- expr = FcExprCreateDouble (vstack->u._double);
+ expr = FcExprCreateDouble (parse->config, vstack->u._double);
break;
case FcVStackMatrix:
- expr = FcExprCreateMatrix (vstack->u.matrix);
+ expr = FcExprCreateMatrix (parse->config, vstack->u.matrix);
break;
case FcVStackBool:
- expr = FcExprCreateBool (vstack->u.bool_);
+ expr = FcExprCreateBool (parse->config, vstack->u.bool_);
break;
case FcVStackTest:
break;
{
if (expr)
{
- new = FcExprCreateOp (left, op, expr);
+ new = FcExprCreateOp (parse->config, left, op, expr);
if (!new)
{
FcConfigMessage (parse, FcSevereError, "out of memory");
if ((operand = FcPopExpr (parse)))
{
- new = FcExprCreateOp (operand, op, 0);
+ new = FcExprCreateOp (parse->config, operand, op, 0);
if (!new)
{
FcExprDestroy (operand);