]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcxml.c
Use GetSystemWindowsDirectory() instead of GetWindowsDirectory() (#22037)
[fontconfig.git] / src / fcxml.c
index 32b8be12cf009b3f05a14f9556a01dcd1b065fec..9dc64e237fae74fb2e406f3bca18993b72e6ee87 100644 (file)
@@ -72,20 +72,9 @@ FcTestDestroy (FcTest *test)
 }
 
 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;
@@ -95,9 +84,9 @@ FcExprCreateInteger (int i)
 }
 
 static FcExpr *
-FcExprCreateDouble (double d)
+FcExprCreateDouble (FcConfig *config, double d)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        e->op = FcOpDouble;
@@ -107,21 +96,21 @@ FcExprCreateDouble (double d)
 }
 
 static FcExpr *
-FcExprCreateString (const FcChar8 *s)
+FcExprCreateString (FcConfig *config, const FcChar8 *s)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        e->op = FcOpString;
-       e->u.sval = FcStrCopy (s);
+       e->u.sval = FcStrStaticName (s);
     }
     return e;
 }
 
 static FcExpr *
-FcExprCreateMatrix (const FcMatrix *m)
+FcExprCreateMatrix (FcConfig *config, const FcMatrix *m)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        e->op = FcOpMatrix;
@@ -131,9 +120,9 @@ FcExprCreateMatrix (const FcMatrix *m)
 }
 
 static FcExpr *
-FcExprCreateBool (FcBool b)
+FcExprCreateBool (FcConfig *config, FcBool b)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        e->op = FcOpBool;
@@ -143,9 +132,9 @@ FcExprCreateBool (FcBool b)
 }
 
 static FcExpr *
-FcExprCreateNil (void)
+FcExprCreateNil (FcConfig *config)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
@@ -155,9 +144,9 @@ FcExprCreateNil (void)
 }
 
 static FcExpr *
-FcExprCreateField (const char *field)
+FcExprCreateField (FcConfig *config, const char *field)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        e->op = FcOpField;
@@ -167,21 +156,21 @@ FcExprCreateField (const char *field)
 }
 
 static FcExpr *
-FcExprCreateConst (const FcChar8 *constant)
+FcExprCreateConst (FcConfig *config, const FcChar8 *constant)
 {
-    FcExpr *e = FcExprAlloc ();
+    FcExpr *e = FcConfigAllocExpr (config);
     if (e)
     {
        e->op = FcOpConst;
-       e->u.constant = FcStrCopy (constant);
+       e->u.constant = FcStrStaticName (constant);
     }
     return e;
 }
 
 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;
@@ -202,7 +191,6 @@ FcExprDestroy (FcExpr *e)
     case FcOpDouble:
        break;
     case FcOpString:
-       FcStrFree (e->u.sval);
        break;
     case FcOpMatrix:
        FcMatrixFree (e->u.mval);
@@ -215,7 +203,6 @@ FcExprDestroy (FcExpr *e)
     case FcOpField:
        break;
     case FcOpConst:
-       FcStrFree (e->u.constant);
        break;
     case FcOpAssign:
     case FcOpAssignReplace:
@@ -254,8 +241,8 @@ FcExprDestroy (FcExpr *e)
     case FcOpInvalid:
        break;
     }
-    FcMemFree (FC_MEM_EXPR, sizeof (FcExpr));
-    free (e);
+
+    e->op = FcOpNil;
 }
 
 void
@@ -849,8 +836,9 @@ FcVStackPopAndDestroy (FcConfigParse *parse)
     switch (vstack->tag) {
     case FcVStackNone:
        break;
-    case FcVStackString:
     case FcVStackFamily:
+       break;
+    case FcVStackString:
     case FcVStackField:
     case FcVStackConstant:
     case FcVStackGlob:
@@ -1337,7 +1325,7 @@ FcParseFamilies (FcConfigParse *parse, FcVStackTag tag)
        FcVStackPopAndDestroy (parse);
        if (expr)
        {
-           new = FcExprCreateOp (left, FcOpComma, expr);
+           new = FcExprCreateOp (parse->config, left, FcOpComma, expr);
            if (!new)
            {
                FcConfigMessage (parse, FcSevereError, "out of memory");
@@ -1374,7 +1362,7 @@ FcParseFamily (FcConfigParse *parse)
        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);
@@ -1397,7 +1385,7 @@ FcParseAlias (FcConfigParse *parse)
        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
@@ -1511,13 +1499,13 @@ FcPopExpr (FcConfigParse *parse)
        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) */
@@ -1529,16 +1517,16 @@ FcPopExpr (FcConfigParse *parse)
        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;
@@ -1573,7 +1561,7 @@ FcPopBinary (FcConfigParse *parse, FcOp op)
     {
        if (expr)
        {
-           new = FcExprCreateOp (left, op, expr);
+           new = FcExprCreateOp (parse->config, left, op, expr);
            if (!new)
            {
                FcConfigMessage (parse, FcSevereError, "out of memory");
@@ -1609,7 +1597,7 @@ FcPopUnary (FcConfigParse *parse, FcOp op)
 
     if ((operand = FcPopExpr (parse)))
     {
-       new = FcExprCreateOp (operand, op, 0);
+       new = FcExprCreateOp (parse->config, operand, op, 0);
        if (!new)
        {
            FcExprDestroy (operand);
@@ -1931,7 +1919,7 @@ FcPopValue (FcConfigParse *parse)
     
     switch (vstack->tag) {
     case FcVStackString:
-       value.u.s = FcStrCopy (vstack->u.string);
+       value.u.s = FcStrStaticName (vstack->u.string);
        if (value.u.s)
            value.type = FcTypeString;
        break;
@@ -2111,10 +2099,10 @@ FcEndElement(void *userData, const XML_Char *name)
                break;
            }
            FcMemAlloc (FC_MEM_STRING, 1000);
-           rc = GetWindowsDirectory (data, 800);
+           rc = GetSystemWindowsDirectory (data, 800);
            if (rc == 0 || rc > 800)
            {
-               FcConfigMessage (parse, FcSevereError, "GetWindowsDirectory failed");
+               FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory failed");
                FcStrFree (data);
                break;
            }
@@ -2154,7 +2142,7 @@ FcEndElement(void *userData, const XML_Char *name)
            rc = GetTempPath (800, data);
            if (rc == 0 || rc > 800)
            {
-               FcConfigMessage (parse, FcSevereError, "GetWindowsDirectory failed");
+               FcConfigMessage (parse, FcSevereError, "GetTempPath failed");
                FcStrFree (data);
                break;
            }