]> git.wh0rd.org - fontconfig.git/commitdiff
Rename FcPatternThawAll to FcPatternFini.
authorCarl Worth <cworth@cworth.org>
Fri, 15 Jul 2005 17:43:44 +0000 (17:43 +0000)
committerCarl Worth <cworth@cworth.org>
Fri, 15 Jul 2005 17:43:44 +0000 (17:43 +0000)
Pull the FcObjectStateName hash table out to file scope, and add
    FcObjectStaticNameFini so that FcFini will cleanup this hash table as
    well.
Clear FILE* to NULL after fclose.

ChangeLog
src/fcinit.c
src/fcint.h
src/fcpat.c
src/fcxml.c

index 2984b0f330247dad8294b038740f1008f43f26c7..d3d9a8197dbff1f7cbd0d9fb82d141a6b71d3ce8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-07-15  Carl Worth  <cworth@cworth.org>
+
+       * src/fcint.h:
+       * src/fcinit.c: (FcFini):
+       * src/fcpat.c: (FcPatternFini): Rename FcPatternThawAll to
+       FcPatternFini.
+       
+       * src/fcpat.c: (FcObjectStaticName), (FcObjectStaticNameFini):
+       Pull the FcObjectStateName hash table out to file scope, and add
+       FcObjectStaticNameFini so that FcFini will cleanup this hash table
+       as well.
+
+       * src/fcxml.c: (FcConfigParseAndLoad): Clear FILE* to NULL after
+       fclose.
+
 2005-06-16  Patrick Lam <plam@MIT.EDU>
 
        reviewed by: keithp
index c3f497bf61947269645b65ed823a47beacd27852..8a9bdbda8c6e1634bdbb39deb60ae221838b1d99 100644 (file)
@@ -116,7 +116,7 @@ FcFini (void)
     if (_fcConfig)
        FcConfigDestroy (_fcConfig);
 
-    FcPatternThawAll ();
+    FcPatternFini ();
     FcCharSetThawAll ();
 }
 
index 24bf246a5e45824784a41ee85f15b7cba97da631..3611df94fc27ac3d8b1624a9ef51cac1f7b1b64e 100644 (file)
@@ -710,7 +710,7 @@ FcPattern *
 FcPatternFreeze (FcPattern *p);
 
 void
-FcPatternThawAll (void);
+FcPatternFini (void);
 
 FcBool
 FcPatternAppend (FcPattern *p, FcPattern *s);
index c886c9258e0fa7887f9a592ffc10e9bcc4d8972c..254faae89f8f86634bf08a4e395034d5fdbfef31 100644 (file)
@@ -579,13 +579,6 @@ bail:
     return n;
 }
 
-void
-FcPatternThawAll (void)
-{
-    FcPatternBaseThawAll ();
-    FcValueListThawAll ();
-}
-
 static int
 FcPatternPosition (const FcPattern *p, const char *object)
 {
@@ -1173,20 +1166,21 @@ FcPatternAppend (FcPattern *p, FcPattern *s)
     return FcTrue;
 }
 
+#define OBJECT_HASH_SIZE    31
+static struct objectBucket {
+    struct objectBucket        *next;
+    FcChar32           hash;
+} *FcObjectBuckets[OBJECT_HASH_SIZE];
+
 const char *
 FcObjectStaticName (const char *name)
 {
-#define OBJECT_HASH_SIZE    31
-    static struct objectBucket {
-       struct objectBucket     *next;
-       FcChar32                hash;
-    } *buckets[OBJECT_HASH_SIZE];
     FcChar32           hash = FcStringHash ((const FcChar8 *) name);
     struct objectBucket        **p;
     struct objectBucket        *b;
     int                        size;
 
-    for (p = &buckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
+    for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
        if (b->hash == hash && !strcmp (name, (char *) (b + 1)))
            return (char *) (b + 1);
     size = sizeof (struct objectBucket) + strlen (name) + 1;
@@ -1200,3 +1194,32 @@ FcObjectStaticName (const char *name)
     *p = b;
     return (char *) (b + 1);
 }
+
+static void
+FcObjectStaticNameFini (void)
+{
+    int i, size;
+    struct objectBucket *b, *next;
+    char *name;
+
+    for (i = 0; i < OBJECT_HASH_SIZE; i++)
+    {
+       for (b = FcObjectBuckets[i]; b; b = next)
+       {
+           next = b->next;
+           name = (char *) (b + 1);
+           size = sizeof (struct objectBucket) + strlen (name) + 1;
+           FcMemFree (FC_MEM_STATICSTR, size);
+           free (b);
+       }
+       FcObjectBuckets[i] = 0;
+    }
+}
+
+void
+FcPatternFini (void)
+{
+    FcPatternBaseThawAll ();
+    FcValueListThawAll ();
+    FcObjectStaticNameFini ();
+}
index 539e57fafb66b3567bc1cdc8ebfb5a2179b47c69..4176c73e874a17b11b566a4b3d5e263f6681c0de 100644 (file)
@@ -2375,6 +2375,7 @@ bail2:
     XML_ParserFree (p);
 bail1:
     fclose (f);
+    f = NULL;
 bail0:
     if (error && complain)
     {