+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
return n;
}
-void
-FcPatternThawAll (void)
-{
- FcPatternBaseThawAll ();
- FcValueListThawAll ();
-}
-
static int
FcPatternPosition (const FcPattern *p, const char *object)
{
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;
*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 ();
+}