]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcpat.c
Change RCS tag
[fontconfig.git] / src / fcpat.c
index 4da57477373de29f3c3df72243fb8ccae4d0b0f7..eb1ebd4ea2e89acb0dedc3b3c088fcf3a0eb020e 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.15 2002/08/22 07:36:45 keithp Exp $
+ * $RCSId: xc/lib/fontconfig/src/fcpat.c,v 1.18 2002/09/18 17:11:46 tsi Exp $
  *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2000 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -276,10 +276,15 @@ typedef struct _FcValueListEnt FcValueListEnt;
 
 struct _FcValueListEnt {
     FcValueListEnt  *next;
-    FcChar32       hash;
     FcValueList            *list;
+    FcChar32       hash, pad;
 };
 
+typedef union _FcValueListAlign {
+    FcValueListEnt  ent;
+    FcValueList            list;
+} FcValueListAlign;
+
 static int         FcValueListFrozenCount[FcTypeLangSet + 1];
 static int         FcValueListFrozenBytes[FcTypeLangSet + 1];
 static char        *FcValueListFrozenName[] = {
@@ -312,6 +317,7 @@ FcValueListReport (void)
 static FcValueListEnt *
 FcValueListEntCreate (FcValueList *h)
 {
+    FcValueListAlign   *ea;
     FcValueListEnt  *e;
     FcValueList            *l, *new;
     int                    n;
@@ -326,17 +332,18 @@ FcValueListEntCreate (FcValueList *h)
            string_size += strlen ((char *) l->value.u.s) + 1;
        n++;
     }
-    size = sizeof (FcValueListEnt) + n * sizeof (FcValueList) + string_size;
+    size = sizeof (FcValueListAlign) + n * sizeof (FcValueList) + string_size;
     FcValueListFrozenCount[h->value.type]++;
     FcValueListFrozenBytes[h->value.type] += size;
-    e = malloc (size);
-    if (!e)
+    ea = malloc (size);
+    if (!ea)
        return 0;
     FcMemAlloc (FC_MEM_VALLIST, size);
-    e->list = (FcValueList *) (e + 1);
+    e = &ea->ent;
+    e->list = (FcValueList *) (ea + 1);
     strs = (FcChar8 *) (e->list + n);
     new = e->list;
-    for (l = h; l; l = l->next)
+    for (l = h; l; l = l->next, new++)
     {
        if (l->value.type == FcTypeString)
        {
@@ -346,7 +353,10 @@ FcValueListEntCreate (FcValueList *h)
            strs += strlen ((char *) strs) + 1;
        }
        else
-           new->value = FcValueSave (l->value);
+       {
+           new->value = l->value;
+           new->value = FcValueSave (new->value);
+       }
        new->binding = l->binding;
        if (l->next)
            new->next = new + 1;
@@ -392,7 +402,7 @@ FcPatternBaseHash (FcPattern *b)
     int                i;
 
     for (i = 0; i < b->num; i++)
-       hash = ((hash << 1) | (hash >> 31)) ^ ((FcChar32) b->elts[i].values);
+       hash = ((hash << 1) | (hash >> 31)) ^ ((long) b->elts[i].values);
     return hash;
 }
 
@@ -846,7 +856,7 @@ FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls)
 }
 
 FcResult
-FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
+FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v)
 {
     FcPatternElt   *e;
     FcValueList    *l;
@@ -867,7 +877,7 @@ FcPatternGet (FcPattern *p, const char *object, int id, FcValue *v)
 }
 
 FcResult
-FcPatternGetInteger (FcPattern *p, const char *object, int id, int *i)
+FcPatternGetInteger (const FcPattern *p, const char *object, int id, int *i)
 {
     FcValue    v;
     FcResult   r;
@@ -889,7 +899,7 @@ FcPatternGetInteger (FcPattern *p, const char *object, int id, int *i)
 }
 
 FcResult
-FcPatternGetDouble (FcPattern *p, const char *object, int id, double *d)
+FcPatternGetDouble (const FcPattern *p, const char *object, int id, double *d)
 {
     FcValue    v;
     FcResult   r;
@@ -911,7 +921,7 @@ FcPatternGetDouble (FcPattern *p, const char *object, int id, double *d)
 }
 
 FcResult
-FcPatternGetString (FcPattern *p, const char *object, int id, FcChar8 ** s)
+FcPatternGetString (const FcPattern *p, const char *object, int id, FcChar8 ** s)
 {
     FcValue    v;
     FcResult   r;
@@ -926,7 +936,7 @@ FcPatternGetString (FcPattern *p, const char *object, int id, FcChar8 ** s)
 }
 
 FcResult
-FcPatternGetMatrix (FcPattern *p, const char *object, int id, FcMatrix **m)
+FcPatternGetMatrix(const FcPattern *p, const char *object, int id, FcMatrix **m)
 {
     FcValue    v;
     FcResult   r;
@@ -942,7 +952,7 @@ FcPatternGetMatrix (FcPattern *p, const char *object, int id, FcMatrix **m)
 
 
 FcResult
-FcPatternGetBool (FcPattern *p, const char *object, int id, FcBool *b)
+FcPatternGetBool(const FcPattern *p, const char *object, int id, FcBool *b)
 {
     FcValue    v;
     FcResult   r;
@@ -957,7 +967,7 @@ FcPatternGetBool (FcPattern *p, const char *object, int id, FcBool *b)
 }
 
 FcResult
-FcPatternGetCharSet (FcPattern *p, const char *object, int id, FcCharSet **c)
+FcPatternGetCharSet(const FcPattern *p, const char *object, int id, FcCharSet **c)
 {
     FcValue    v;
     FcResult   r;
@@ -972,7 +982,7 @@ FcPatternGetCharSet (FcPattern *p, const char *object, int id, FcCharSet **c)
 }
 
 FcResult
-FcPatternGetFTFace (FcPattern *p, const char *object, int id, FT_Face *f)
+FcPatternGetFTFace(const FcPattern *p, const char *object, int id, FT_Face *f)
 {
     FcValue    v;
     FcResult   r;
@@ -987,7 +997,7 @@ FcPatternGetFTFace (FcPattern *p, const char *object, int id, FT_Face *f)
 }
 
 FcResult
-FcPatternGetLangSet (FcPattern *p, const char *object, int id, FcLangSet **ls)
+FcPatternGetLangSet(const FcPattern *p, const char *object, int id, FcLangSet **ls)
 {
     FcValue    v;
     FcResult   r;
@@ -1002,7 +1012,7 @@ FcPatternGetLangSet (FcPattern *p, const char *object, int id, FcLangSet **ls)
 }
 
 FcPattern *
-FcPatternDuplicate (FcPattern *orig)
+FcPatternDuplicate (const FcPattern *orig)
 {
     FcPattern      *new;
     int                    i;