Fix a few memory tracking mistakes.

The built-in memory tracking code in fontconfig relies on a lot of manual
function call tracking. A pain, but it helps debug leaks.
This commit is contained in:
Keith Packard 2008-05-04 01:26:40 -07:00
parent c6c9400d67
commit 13a14cbf56
5 changed files with 17 additions and 4 deletions

View File

@ -205,7 +205,7 @@ void
FcAtomicDestroy (FcAtomic *atomic)
{
FcMemFree (FC_MEM_ATOMIC, sizeof (FcAtomic) +
strlen ((char *) atomic->file) * 4 + 1 +
strlen ((char *) atomic->file) * 4 + 4 +
sizeof (NEW_NAME) + sizeof (LCK_NAME) +
sizeof (TMP_NAME));

View File

@ -1239,6 +1239,9 @@ FcCharSetFreezerDestroy (FcCharSetFreezer *freezer)
for (ent = freezer->set_hash_table[i]; ent; ent = next)
{
next = ent->next;
FcMemFree (FC_MEM_CHARSET, (sizeof (FcCharSetEnt) +
ent->set.num * sizeof (FcCharLeaf *) +
ent->set.num * sizeof (FcChar16)));
free (ent);
}
}
@ -1254,7 +1257,10 @@ FcCharSetFreezerDestroy (FcCharSetFreezer *freezer)
}
for (i = 0; i < freezer->leaf_block_count; i++)
{
free (freezer->leaf_blocks[i]);
FcMemFree (FC_MEM_CHARLEAF, FC_CHAR_LEAF_BLOCK * sizeof (FcCharLeafEnt));
}
free (freezer->leaf_blocks);
free (freezer);

View File

@ -141,6 +141,8 @@ FcFini (void)
FcPatternFini ();
FcCacheFini ();
if (FcDebug() & FC_DBG_MEMORY)
FcMemReport ();
}
/*

View File

@ -1054,7 +1054,7 @@ FcStrStaticNameFini (void)
next = b->next;
name = (char *) (b + 1);
size = sizeof (struct objectBucket) + strlen (name) + 1;
FcMemFree (FC_MEM_STATICSTR, size);
FcMemFree (FC_MEM_STATICSTR, size + sizeof (int));
free (b);
}
FcObjectBuckets[i] = 0;

View File

@ -1025,11 +1025,14 @@ _FcStrSetAppend (FcStrSet *set, FcChar8 *s)
if (!strs)
return FcFalse;
FcMemAlloc (FC_MEM_STRSET, (set->size + 2) * sizeof (FcChar8 *));
set->size = set->size + 1;
if (set->num)
memcpy (strs, set->strs, set->num * sizeof (FcChar8 *));
if (set->strs)
{
FcMemFree (FC_MEM_STRSET, (set->size + 1) * sizeof (FcChar8 *));
free (set->strs);
}
set->size = set->size + 1;
set->strs = strs;
}
set->strs[set->num++] = s;
@ -1118,9 +1121,11 @@ FcStrSetDestroy (FcStrSet *set)
for (i = 0; i < set->num; i++)
FcStrFree (set->strs[i]);
FcMemFree (FC_MEM_STRSET, (set->size) * sizeof (FcChar8 *));
if (set->strs)
{
FcMemFree (FC_MEM_STRSET, (set->size + 1) * sizeof (FcChar8 *));
free (set->strs);
}
FcMemFree (FC_MEM_STRSET, sizeof (FcStrSet));
free (set);
}