]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcpat.c
[int] Remove fc_storage_type() in favor of direct access to v->type
[fontconfig.git] / src / fcpat.c
index f9b533cf3e7c92da7434022194a4040a2010935a..90d42cacd636218a2c00dff95fa84650cf557a00 100644 (file)
@@ -11,9 +11,9 @@
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
@@ -27,7 +27,7 @@
 #include <assert.h>
 
 static FcBool
-FcStrHashed (const FcChar8 *name);
+FcHashOwnsName(const FcChar8 *name);
 
 FcPattern *
 FcPatternCreate (void)
@@ -50,7 +50,7 @@ FcValueDestroy (FcValue v)
 {
     switch (v.type) {
     case FcTypeString:
-        if (!FcStrHashed (v.u.s))
+        if (!FcHashOwnsName(v.u.s))
             FcStrFree ((FcChar8 *) v.u.s);
        break;
     case FcTypeMatrix:
@@ -98,7 +98,7 @@ FcValueSave (FcValue v)
 {
     switch (v.type) {
     case FcTypeString:
-       v.u.s = FcStrCopy (v.u.s);
+       v.u.s = FcStrStaticName (v.u.s);
        if (!v.u.s)
            v.type = FcTypeVoid;
        break;
@@ -131,7 +131,7 @@ FcValueListDestroy (FcValueListPtr l)
     {
        switch (l->value.type) {
        case FcTypeString:
-            if (!FcStrHashed ((FcChar8 *)l->value.u.s))
+            if (!FcHashOwnsName((FcChar8 *)l->value.u.s))
                 FcStrFree ((FcChar8 *)l->value.u.s);
            break;
        case FcTypeMatrix:
@@ -220,7 +220,7 @@ FcStringHash (const FcChar8 *s)
 static FcChar32
 FcValueHash (const FcValue *v)
 {
-    switch (fc_storage_type(v)) {
+    switch (v->type) {
     case FcTypeVoid:
        return 0;
     case FcTypeInteger:
@@ -482,15 +482,7 @@ FcPatternObjectAddWithBinding  (FcPattern  *p,
 
     memset(new, 0, sizeof (FcValueList));
     FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList));
-    /* dup string */
-    if (value.type == FcTypeString)
-    {
-       value.u.s = FcStrStaticName (value.u.s);
-       if (!value.u.s)
-           value.type = FcTypeVoid;
-    }
-    else
-       value = FcValueSave (value);
+    value = FcValueSave (value);
     if (value.type == FcTypeVoid)
        goto bail1;
 
@@ -1027,7 +1019,7 @@ FcPatternFilter (FcPattern *p, const FcObjectSet *os)
            }
        }
     }
-    return p;
+    return ret;
 
 bail0:
     FcPatternDestroy (ret);
@@ -1041,14 +1033,14 @@ static struct objectBucket {
 } *FcObjectBuckets[OBJECT_HASH_SIZE];
 
 static FcBool
-FcStrHashed (const FcChar8 *name)
+FcHashOwnsName (const FcChar8 *name)
 {
     FcChar32           hash = FcStringHash (name);
     struct objectBucket        **p;
     struct objectBucket        *b;
 
     for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
-       if (b->hash == hash && !strcmp ((char *)name, (char *) (b + 1)))
+       if (b->hash == hash && ((char *)name == (char *) (b + 1)))
             return FcTrue;
     return FcFalse;
 }