+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)
{
struct objectBucket *next;
FcChar32 hash;
};
-static struct objectBucket **buckets = 0;
+static struct objectBucket **FcObjectBuckets = 0;
FcObjectPtr
FcObjectStaticName (const char *name)
int size;
FcObjectPtr new;
- if (!buckets)
+ if (!FcObjectBuckets)
{
- buckets = malloc(sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
- memset (buckets, 0, sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
+ FcObjectBuckets = malloc(sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
+ memset (FcObjectBuckets, 0, sizeof (struct objectBucket *)*OBJECT_HASH_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))
{
FcObjectPtr bp = *((FcObjectPtr *) (b + 1));
if (b->hash == hash && FcObjectPtrU(bp) && !strcmp (name, FcObjectPtrU(bp)))
objectptr_alloc = s;
}
- size = sizeof (struct objectBucket) + sizeof (FcObjectPtr);
+ size = sizeof (struct objectBucket) + strlen (name) + 1;
b = malloc (size);
if (!b)
return 0;
int i;
struct objectBucket *b, *bn;
- if (buckets)
+ if (FcObjectBuckets)
{
for (i = 0; i < OBJECT_HASH_SIZE; i++)
{
- b = buckets[i];
+ b = FcObjectBuckets[i];
while (b)
{
bn = b->next;
b = bn;
}
}
- free (buckets);
+ free (FcObjectBuckets);
}
- buckets = malloc(sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
- memset (buckets, 0, sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
+ FcObjectBuckets = malloc(sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
+ memset (FcObjectBuckets, 0, sizeof (struct objectBucket *)*OBJECT_HASH_SIZE);
for (i = 1; i < objectptr_count; i++)
{
struct objectBucket **p;
int size;
- for (p = &buckets[hash % OBJECT_HASH_SIZE]; (b = *p);
+ for (p = &FcObjectBuckets[hash % OBJECT_HASH_SIZE]; (b = *p);
p = &(b->next))
;
size = sizeof (struct objectBucket) + sizeof (FcObjectPtr);
bail:
return FcFalse;
}
+
+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 ();
+}