diff options
author | Patrick Lam <plam@MIT.EDU> | 2005-07-15 18:49:12 +0000 |
---|---|---|
committer | Patrick Lam <plam@MIT.EDU> | 2005-07-15 18:49:12 +0000 |
commit | e1b9d091c661b0e1d1e9f73c5c55ad53959c55c7 (patch) | |
tree | a0af1dc3365fb9c85bf39f5c96bc8ccaf8b11a29 /src | |
parent | 0fa680f0766a8f545b20a7935a19e9db5529f903 (diff) |
Forward port cworth's patch to branch.
Diffstat (limited to 'src')
-rw-r--r-- | src/fcinit.c | 2 | ||||
-rw-r--r-- | src/fcint.h | 2 | ||||
-rw-r--r-- | src/fcpat.c | 60 | ||||
-rw-r--r-- | src/fcxml.c | 1 |
4 files changed, 44 insertions, 21 deletions
diff --git a/src/fcinit.c b/src/fcinit.c index c3f497bf..8a9bdbda 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -116,7 +116,7 @@ FcFini (void) if (_fcConfig) FcConfigDestroy (_fcConfig); - FcPatternThawAll (); + FcPatternFini (); FcCharSetThawAll (); } diff --git a/src/fcint.h b/src/fcint.h index fe2c095c..f29b4597 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -812,7 +812,7 @@ FcPattern * FcPatternFreeze (FcPattern *p); void -FcPatternThawAll (void); +FcPatternFini (void); FcBool FcPatternAppend (FcPattern *p, FcPattern *s); diff --git a/src/fcpat.c b/src/fcpat.c index 9f8fe14a..0633c5ac 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -651,13 +651,6 @@ FcPatternFreeze (FcPattern *p) return n; } -void -FcPatternThawAll (void) -{ - FcPatternBaseThawAll (); - FcValueListThawAll (); -} - static int FcPatternPosition (const FcPattern *p, const char *object) { @@ -1584,7 +1577,7 @@ struct objectBucket { struct objectBucket *next; FcChar32 hash; }; -static struct objectBucket **buckets = 0; +static struct objectBucket **FcObjectBuckets = 0; FcObjectPtr FcObjectStaticName (const char *name) @@ -1596,13 +1589,13 @@ 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))) @@ -1649,7 +1642,7 @@ FcObjectStaticName (const char *name) objectptr_alloc = s; } - size = sizeof (struct objectBucket) + sizeof (FcObjectPtr); + size = sizeof (struct objectBucket) + strlen (name) + 1; b = malloc (size); if (!b) return 0; @@ -1709,11 +1702,11 @@ FcObjectRebuildStaticNameHashtable (void) 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; @@ -1723,11 +1716,11 @@ FcObjectRebuildStaticNameHashtable (void) 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++) { @@ -1738,7 +1731,7 @@ FcObjectRebuildStaticNameHashtable (void) 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); @@ -1948,3 +1941,32 @@ FcObjectPrepareSerialize (FcObjectPtr si) 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 (); +} diff --git a/src/fcxml.c b/src/fcxml.c index 1256bed4..d982755e 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -2374,6 +2374,7 @@ bail2: XML_ParserFree (p); bail1: fclose (f); + f = NULL; bail0: if (error && complain) { |