fontconfig: Branch 'wip/threadsafe'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 src/fcpat.c |   62 ++++++++----------------------------------------------------
 1 file changed, 9 insertions(+), 53 deletions(-)

New commits:
commit 6a64ca1e9f718d761136f672404e7737a651a306
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Sat Oct 6 18:12:19 2012 -0400

    Remove shared-str pool
    
    We used to have a shared-str pool.  Removed to make thread-safety
    work easier.  My measurements show that the extra overhead is not
    significant by any means.

diff --git a/src/fcpat.c b/src/fcpat.c
index ebd6e57..92b4cc4 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -1023,68 +1023,24 @@ bail0:
     return NULL;
 }
 
-#define OBJECT_HASH_SIZE    251
-static struct objectBucket {
-    struct objectBucket	*next;
-    FcChar32		hash;
-    int			ref_count;
-} *FcObjectBuckets[OBJECT_HASH_SIZE];
+
+/* We used to have a shared-str pool.  Removed to make thread-safety
+ * work easier.  My measurements show that the extra overhead is not
+ * significant by any means. */
 
 FcBool
 FcSharedStrFree (const FcChar8 *name)
 {
-    FcChar32		hash = FcStringHash (name);
-    struct objectBucket	**p;
-    struct objectBucket	*b;
-    int			size;
-
-    for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
-	if (b->hash == hash && ((char *)name == (char *) (b + 1)))
-	{
-	    b->ref_count--;
-	    if (!b->ref_count)
-	    {
-		*p = b->next;
-		size = sizeof (struct objectBucket) + strlen ((char *)name) + 1;
-		size = (size + 3) & ~3;
-		FcMemFree (FC_MEM_SHAREDSTR, size);
-		free (b);
-	    }
-            return FcTrue;
-	}
-    return FcFalse;
+  free (name);
+  FcMemFree (FC_MEM_SHAREDSTR, 8);
+  return FcTrue;
 }
 
 const FcChar8 *
 FcSharedStr (const FcChar8 *name)
 {
-    FcChar32		hash = FcStringHash (name);
-    struct objectBucket	**p;
-    struct objectBucket	*b;
-    int			size;
-
-    for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
-	if (b->hash == hash && !strcmp ((char *)name, (char *) (b + 1)))
-	{
-	    b->ref_count++;
-	    return (FcChar8 *) (b + 1);
-	}
-    size = sizeof (struct objectBucket) + strlen ((char *)name) + 1;
-    /*
-     * workaround valgrind warning because glibc takes advantage of how it knows memory is
-     * allocated to implement strlen by reading in groups of 4
-     */
-    size = (size + 3) & ~3;
-    b = malloc (size);
-    FcMemAlloc (FC_MEM_SHAREDSTR, size);
-    if (!b)
-        return NULL;
-    b->next = 0;
-    b->hash = hash;
-    b->ref_count = 1;
-    strcpy ((char *) (b + 1), (char *)name);
-    *p = b;
-    return (FcChar8 *) (b + 1);
+  FcMemAlloc (FC_MEM_SHAREDSTR, 8);
+  return strdup (name);
 }
 
 FcBool
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig


[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux