More complete memory tracking. Install always overwrites header files

This commit is contained in:
Keith Packard 2002-08-31 22:17:32 +00:00
parent cb30af7204
commit 9dac3c5945
15 changed files with 150 additions and 60 deletions

View File

@ -1,5 +1,5 @@
# #
# $XFree86: xc/lib/fontconfig/fontconfig/Makefile.in,v 1.2 2002/05/24 06:25:52 keithp Exp $ # $XFree86: xc/lib/fontconfig/fontconfig/Makefile.in,v 1.3 2002/08/01 15:57:26 keithp Exp $
# #
# Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. # Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
# #
@ -29,20 +29,11 @@ include $(TOPDIR)/config/Makedefs
all:: all::
install:: $(DESTDIR)$(INCLUDEDIR) install:: $(DESTDIR)$(INCLUDEDIR)
install:: $(DESTDIR)$(INCLUDEDIR)/fcfreetype.h $(INSTALL_DATA) fcfreetype.h $(DESTDIR)$(INCLUDEDIR)/fcfreetype.h
install:: $(DESTDIR)$(INCLUDEDIR)/fcprivate.h $(INSTALL_DATA) fcprivate.h $(DESTDIR)$(INCLUDEDIR)/fcprivate.h
install:: $(DESTDIR)$(INCLUDEDIR)/fontconfig.h $(INSTALL_DATA) fontconfig.h $(DESTDIR)$(INCLUDEDIR)/fontconfig.h
$(DESTDIR)$(INCLUDEDIR): $(DESTDIR)$(INCLUDEDIR):
mkdir -p $@ mkdir -p $@
$(DESTDIR)$(INCLUDEDIR)/fcfreetype.h: fcfreetype.h
$(INSTALL_DATA) $< $(DESTDIR)$(INCLUDEDIR)/$<
$(DESTDIR)$(INCLUDEDIR)/fcprivate.h: fcprivate.h
$(INSTALL_DATA) $< $(DESTDIR)$(INCLUDEDIR)/$<
$(DESTDIR)$(INCLUDEDIR)/fontconfig.h: fontconfig.h
$(INSTALL_DATA) $< $(DESTDIR)$(INCLUDEDIR)/$<
clean:: clean::

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcatomic.c,v 1.1 2002/03/03 00:19:43 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcatomic.c,v 1.2 2002/03/04 21:15:28 tsi Exp $
* *
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -70,6 +70,7 @@ FcAtomicCreate (const FcChar8 *file)
FcAtomic *atomic = malloc (total_len); FcAtomic *atomic = malloc (total_len);
if (!atomic) if (!atomic)
return 0; return 0;
FcMemAlloc (FC_MEM_ATOMIC, total_len);
atomic->file = (FcChar8 *) (atomic + 1); atomic->file = (FcChar8 *) (atomic + 1);
strcpy ((char *) atomic->file, (char *) file); strcpy ((char *) atomic->file, (char *) file);
@ -179,5 +180,10 @@ FcAtomicUnlock (FcAtomic *atomic)
void void
FcAtomicDestroy (FcAtomic *atomic) FcAtomicDestroy (FcAtomic *atomic)
{ {
FcMemFree (FC_MEM_ATOMIC, sizeof (FcAtomic) +
strlen ((char *) atomic->file) * 4 + 1 +
sizeof (NEW_NAME) + sizeof (LCK_NAME) +
sizeof (TMP_NAME));
free (atomic); free (atomic);
} }

View File

@ -32,6 +32,7 @@ FcBlanksCreate (void)
b = malloc (sizeof (FcBlanks)); b = malloc (sizeof (FcBlanks));
if (!b) if (!b)
return 0; return 0;
FcMemAlloc (FC_MEM_BLANKS, sizeof (FcBlanks));
b->nblank = 0; b->nblank = 0;
b->sblank = 0; b->sblank = 0;
b->blanks = 0; b->blanks = 0;
@ -42,7 +43,11 @@ void
FcBlanksDestroy (FcBlanks *b) FcBlanksDestroy (FcBlanks *b)
{ {
if (b->blanks) if (b->blanks)
{
FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32));
free (b->blanks); free (b->blanks);
}
FcMemFree (FC_MEM_BLANKS, sizeof (FcBlanks));
free (b); free (b);
} }
@ -65,6 +70,9 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
c = (FcChar32 *) malloc (sblank * sizeof (FcChar32)); c = (FcChar32 *) malloc (sblank * sizeof (FcChar32));
if (!c) if (!c)
return FcFalse; return FcFalse;
if (b->sblank)
FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32));
FcMemAlloc (FC_MEM_BLANKS, sblank * sizeof (FcChar32));
b->sblank = sblank; b->sblank = sblank;
b->blanks = c; b->blanks = c;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fccache.c,v 1.11 2002/08/19 19:32:05 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fccache.c,v 1.12 2002/08/22 07:36:44 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -77,7 +77,7 @@ FcCacheReadString (FILE *f, FcChar8 *dest, int len)
} }
if (i == size) if (i == size)
{ {
FcChar8 *new = malloc (size * 2); FcChar8 *new = malloc (size * 2); /* freed in caller */
if (!new) if (!new)
break; break;
memcpy (new, d, size); memcpy (new, d, size);
@ -253,7 +253,7 @@ FcCacheFontSetAdd (FcFontSet *set,
len = (dir_len + 1 + strlen ((const char *) file) + 1); len = (dir_len + 1 + strlen ((const char *) file) + 1);
if (len > sizeof (path_buf)) if (len > sizeof (path_buf))
{ {
path = malloc (len); path = malloc (len); /* freed down below */
if (!path) if (!path)
return FcFalse; return FcFalse;
} }
@ -406,6 +406,7 @@ FcGlobalCacheDirGet (FcGlobalCache *cache,
d = malloc (sizeof (FcGlobalCacheDir) + len + 1); d = malloc (sizeof (FcGlobalCacheDir) + len + 1);
if (!d) if (!d)
return 0; return 0;
FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCacheDir) + len + 1);
d->next = *prev; d->next = *prev;
*prev = d; *prev = d;
d->info.hash = hash; d->info.hash = hash;
@ -451,6 +452,8 @@ FcGlobalCacheDirAdd (FcGlobalCache *cache,
strlen ((const char *) i.base) + 1); strlen ((const char *) i.base) + 1);
if (!subdir) if (!subdir)
return 0; return 0;
FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir) +
strlen ((const char *) i.base) + 1);
subdir->file = (FcChar8 *) (subdir + 1); subdir->file = (FcChar8 *) (subdir + 1);
strcpy ((char *) subdir->file, (const char *) i.base); strcpy ((char *) subdir->file, (const char *) i.base);
subdir->next = parent->subdirs; subdir->next = parent->subdirs;
@ -469,13 +472,19 @@ FcGlobalCacheDirDestroy (FcGlobalCacheDir *d)
for (f = d->ents[h]; f; f = next) for (f = d->ents[h]; f; f = next)
{ {
next = f->next; next = f->next;
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheFile) +
strlen ((char *) f->info.file) + 1 +
strlen ((char *) f->name) + 1);
free (f); free (f);
} }
for (s = d->subdirs; s; s = nexts) for (s = d->subdirs; s; s = nexts)
{ {
nexts = s->next; nexts = s->next;
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir) +
strlen ((char *) s->file) + 1);
free (s); free (s);
} }
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheDir) + d->len + 1);
free (d); free (d);
} }
@ -587,6 +596,7 @@ FcGlobalCacheFileAdd (FcGlobalCache *cache,
FcGlobalCacheDir *d = FcGlobalCacheDirGet (cache, i.dir, FcGlobalCacheDir *d = FcGlobalCacheDirGet (cache, i.dir,
i.dir_len, FcTrue); i.dir_len, FcTrue);
FcGlobalCacheFile *f, **prev; FcGlobalCacheFile *f, **prev;
int size;
if (!d) if (!d)
return 0; return 0;
@ -610,13 +620,18 @@ FcGlobalCacheFileAdd (FcGlobalCache *cache,
if (f->info.referenced) if (f->info.referenced)
cache->referenced--; cache->referenced--;
*prev = f->next; *prev = f->next;
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheFile) +
strlen ((char *) f->info.file) + 1 +
strlen ((char *) f->name) + 1);
free (f); free (f);
} }
f = malloc (sizeof (FcGlobalCacheFile) + size = (sizeof (FcGlobalCacheFile) +
strlen ((char *) i.base) + 1 + strlen ((char *) i.base) + 1 +
strlen ((char *) name) + 1); strlen ((char *) name) + 1);
f = malloc (size);
if (!f) if (!f)
return 0; return 0;
FcMemAlloc (FC_MEM_CACHE, size);
f->next = *prev; f->next = *prev;
*prev = f; *prev = f;
f->info.hash = i.base_hash; f->info.hash = i.base_hash;
@ -639,6 +654,7 @@ FcGlobalCacheCreate (void)
cache = malloc (sizeof (FcGlobalCache)); cache = malloc (sizeof (FcGlobalCache));
if (!cache) if (!cache)
return 0; return 0;
FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCache));
for (h = 0; h < FC_GLOBAL_CACHE_DIR_HASH_SIZE; h++) for (h = 0; h < FC_GLOBAL_CACHE_DIR_HASH_SIZE; h++)
cache->ents[h] = 0; cache->ents[h] = 0;
cache->entries = 0; cache->entries = 0;
@ -662,6 +678,7 @@ FcGlobalCacheDestroy (FcGlobalCache *cache)
FcGlobalCacheDirDestroy (d); FcGlobalCacheDirDestroy (d);
} }
} }
FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCache));
free (cache); free (cache);
} }
@ -946,7 +963,7 @@ bail3:
bail2: bail2:
fclose (f); fclose (f);
bail1: bail1:
free (cache_file); FcStrFree (cache_file);
bail0: bail0:
return ret; return ret;
} }
@ -1036,7 +1053,7 @@ FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
if (!name) if (!name)
goto bail3; goto bail3;
ret = FcCacheWriteString (f, name); ret = FcCacheWriteString (f, name);
free (name); FcStrFree (name);
if (!ret) if (!ret)
goto bail3; goto bail3;
if (PUTC ('\n', f) == EOF) if (PUTC ('\n', f) == EOF)
@ -1048,7 +1065,7 @@ FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
if (fclose (f) == EOF) if (fclose (f) == EOF)
goto bail1; goto bail1;
free (cache_file); FcStrFree (cache_file);
if (FcDebug () & FC_DBG_CACHE) if (FcDebug () & FC_DBG_CACHE)
printf (" cache written\n"); printf (" cache written\n");
@ -1060,7 +1077,7 @@ bail2:
fclose (f); fclose (f);
bail1: bail1:
unlink ((char *) cache_file); unlink ((char *) cache_file);
free (cache_file); FcStrFree (cache_file);
bail0: bail0:
return FcFalse; return FcFalse;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.21 2002/08/22 07:36:44 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fccfg.c,v 1.22 2002/08/22 18:53:22 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -429,6 +429,7 @@ FcConfigAddEdit (FcConfig *config,
subst = (FcSubst *) malloc (sizeof (FcSubst)); subst = (FcSubst *) malloc (sizeof (FcSubst));
if (!subst) if (!subst)
return FcFalse; return FcFalse;
FcMemAlloc (FC_MEM_SUBST, sizeof (FcSubst));
if (kind == FcMatchPattern) if (kind == FcMatchPattern)
prev = &config->substPattern; prev = &config->substPattern;
else else
@ -1274,10 +1275,11 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
strcat ((char *) path, "/"); strcat ((char *) path, "/");
strcat ((char *) path, (char *) file); strcat ((char *) path, (char *) file);
FcMemAlloc (FC_MEM_STRING, strlen ((char *) path) + 1);
if (access ((char *) path, R_OK) == 0) if (access ((char *) path, R_OK) == 0)
return path; return path;
free (path); FcStrFree (path);
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.17 2002/07/13 05:43:25 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.18 2002/08/22 07:36:44 keithp Exp $
* *
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -142,7 +142,9 @@ FcCharSetPutLeaf (FcCharSet *fcs,
leaves = realloc (fcs->leaves, (fcs->num + 1) * sizeof (FcCharLeaf *)); leaves = realloc (fcs->leaves, (fcs->num + 1) * sizeof (FcCharLeaf *));
if (!leaves) if (!leaves)
return FcFalse; return FcFalse;
FcMemAlloc (FC_MEM_CHARSET, sizeof (FcCharLeaf *)); if (fcs->num)
FcMemFree (FC_MEM_CHARSET, fcs->num * sizeof (FcCharLeaf *));
FcMemAlloc (FC_MEM_CHARSET, (fcs->num + 1) * sizeof (FcCharLeaf *));
fcs->leaves = leaves; fcs->leaves = leaves;
if (!fcs->numbers) if (!fcs->numbers)
numbers = malloc (sizeof (FcChar16)); numbers = malloc (sizeof (FcChar16));
@ -150,7 +152,9 @@ FcCharSetPutLeaf (FcCharSet *fcs,
numbers = realloc (fcs->numbers, (fcs->num + 1) * sizeof (FcChar16)); numbers = realloc (fcs->numbers, (fcs->num + 1) * sizeof (FcChar16));
if (!numbers) if (!numbers)
return FcFalse; return FcFalse;
FcMemAlloc (FC_MEM_CHARSET, sizeof (FcChar16)); if (fcs->num)
FcMemFree (FC_MEM_CHARSET, fcs->num * sizeof (FcChar16));
FcMemAlloc (FC_MEM_CHARSET, (fcs->num + 1) * sizeof (FcChar16));
fcs->numbers = numbers; fcs->numbers = numbers;
memmove (fcs->leaves + pos + 1, fcs->leaves + pos, memmove (fcs->leaves + pos + 1, fcs->leaves + pos,

View File

@ -129,7 +129,7 @@ FcFileScan (FcFontSet *set,
if (unparse) if (unparse)
{ {
(void) FcGlobalCacheUpdate (cache, file, id, unparse); (void) FcGlobalCacheUpdate (cache, file, id, unparse);
free (unparse); FcStrFree (unparse);
} }
} }
} }
@ -181,6 +181,7 @@ FcDirScan (FcFontSet *set,
return FcTrue; return FcTrue;
} }
/* freed below */
file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + FC_MAX_FILE_LEN + 1); file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + FC_MAX_FILE_LEN + 1);
if (!file) if (!file)
return FcFalse; return FcFalse;

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcfreetype.c,v 1.9 2002/07/13 05:43:25 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcfreetype.c,v 1.10 2002/08/22 07:36:44 keithp Exp $
* *
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -305,7 +305,7 @@ FcFreeTypeQuery (const FcChar8 *file,
continue; continue;
/* /*
* Allocate plenty of space * Allocate plenty of space. Freed below
*/ */
utf8 = malloc (len * FC_UTF8_MAX_LEN + 1); utf8 = malloc (len * FC_UTF8_MAX_LEN + 1);
if (!utf8) if (!utf8)
@ -324,7 +324,7 @@ FcFreeTypeQuery (const FcChar8 *file,
break; break;
case FcNameEncodingLatin1: case FcNameEncodingLatin1:
/* /*
* Convert Latin1 to Utf8 * Convert Latin1 to Utf8. Freed below
*/ */
utf8 = malloc (src_len * 2 + 1); utf8 = malloc (src_len * 2 + 1);
if (!utf8) if (!utf8)
@ -348,6 +348,7 @@ FcFreeTypeQuery (const FcChar8 *file,
if (!map) if (!map)
continue; continue;
/* freed below */
utf8 = malloc (src_len * 3 + 1); utf8 = malloc (src_len * 3 + 1);
if (!utf8) if (!utf8)
continue; continue;
@ -422,6 +423,7 @@ FcFreeTypeQuery (const FcChar8 *file,
end = (FcChar8 *) strrchr ((char *) start, '.'); end = (FcChar8 *) strrchr ((char *) start, '.');
if (!end) if (!end)
end = start + strlen ((char *) start); end = start + strlen ((char *) start);
/* freed below */
family = malloc (end - start + 1); family = malloc (end - start + 1);
strncpy ((char *) family, (char *) start, end - start); strncpy ((char *) family, (char *) start, end - start);
family[end - start] = '\0'; family[end - start] = '\0';

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcinit.c,v 1.6 2002/05/23 23:00:46 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcinit.c,v 1.7 2002/08/22 07:36:44 keithp Exp $
* *
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -154,23 +154,35 @@ static struct {
int free_count; int free_count;
int free_mem; int free_mem;
} FcInUse[FC_MEM_NUM] = { } FcInUse[FC_MEM_NUM] = {
{ "charset", 0, 0 }, { "charset" },
{ "charleaf", 0 ,0 }, { "charleaf" },
{ "fontset", 0, 0 }, { "fontset" },
{ "fontptr", 0, 0 }, { "fontptr" },
{ "objectset", 0, 0 }, { "objectset" },
{ "objectptr", 0, 0 }, { "objectptr" },
{ "matrix", 0, 0 }, { "matrix" },
{ "pattern", 0, 0 }, { "pattern" },
{ "patelt", 0, 0 }, { "patelt" },
{ "vallist", 0, 0 }, { "vallist" },
{ "substate", 0, 0 }, { "substate" },
{ "string", 0, 0 }, { "string" },
{ "listbuck", 0, 0 }, { "listbuck" },
{ "strset", 0, 0 }, { "strset" },
{ "strlist", 0, 0 }, { "strlist" },
{ "config", 0, 0 }, { "config" },
{ "langset", 0, 0 }, { "langset" },
{ "atomic" },
{ "blanks" },
{ "cache" },
{ "strbuf" },
{ "subst" },
{ "objecttype" },
{ "constant" },
{ "test" },
{ "expr" },
{ "vstack" },
{ "attr" },
{ "pstack" },
}; };
static int FcAllocCount, FcAllocMem; static int FcAllocCount, FcAllocMem;

View File

@ -81,8 +81,20 @@ typedef struct _FcSymbolic {
#define FC_MEM_STRLIST 14 #define FC_MEM_STRLIST 14
#define FC_MEM_CONFIG 15 #define FC_MEM_CONFIG 15
#define FC_MEM_LANGSET 16 #define FC_MEM_LANGSET 16
#define FC_MEM_ATOMIC 17
#define FC_MEM_BLANKS 18
#define FC_MEM_CACHE 19
#define FC_MEM_STRBUF 20
#define FC_MEM_SUBST 21
#define FC_MEM_OBJECTTYPE 22
#define FC_MEM_CONSTANT 23
#define FC_MEM_TEST 24
#define FC_MEM_EXPR 25
#define FC_MEM_VSTACK 26
#define FC_MEM_ATTR 27
#define FC_MEM_PSTACK 28
#define FC_MEM_NUM 17 #define FC_MEM_NUM 29
typedef enum _FcValueBinding { typedef enum _FcValueBinding {
FcValueBindingWeak, FcValueBindingStrong FcValueBindingWeak, FcValueBindingStrong

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.18 2002/08/19 19:32:05 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.19 2002/08/22 07:36:44 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -640,6 +640,7 @@ FcFontSetSort (FcConfig *config,
} }
if (!nnodes) if (!nnodes)
goto bail0; goto bail0;
/* freed below */
nodes = malloc (nnodes * sizeof (FcSortNode) + nnodes * sizeof (FcSortNode *)); nodes = malloc (nnodes * sizeof (FcSortNode) + nnodes * sizeof (FcSortNode *));
if (!nodes) if (!nodes)
goto bail0; goto bail0;

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.12 2002/08/19 19:32:05 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.13 2002/08/22 07:36:45 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -88,6 +88,7 @@ FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes)
l = (FcObjectTypeList *) malloc (sizeof (FcObjectTypeList)); l = (FcObjectTypeList *) malloc (sizeof (FcObjectTypeList));
if (!l) if (!l)
return FcFalse; return FcFalse;
FcMemAlloc (FC_MEM_OBJECTTYPE, sizeof (FcObjectTypeList));
l->types = types; l->types = types;
l->ntypes = ntypes; l->ntypes = ntypes;
l->next = _FcObjectTypes; l->next = _FcObjectTypes;
@ -107,6 +108,7 @@ FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes)
if (l->types == types && l->ntypes == ntypes) if (l->types == types && l->ntypes == ntypes)
{ {
*prev = l->next; *prev = l->next;
FcMemFree (FC_MEM_OBJECTTYPE, sizeof (FcObjectTypeList));
free ((void *) l); free ((void *) l);
return FcTrue; return FcTrue;
} }
@ -181,6 +183,7 @@ FcNameRegisterConstants (const FcConstant *consts, int nconsts)
l = (FcConstantList *) malloc (sizeof (FcConstantList)); l = (FcConstantList *) malloc (sizeof (FcConstantList));
if (!l) if (!l)
return FcFalse; return FcFalse;
FcMemAlloc (FC_MEM_CONSTANT, sizeof (FcConstantList));
l->consts = consts; l->consts = consts;
l->nconsts = nconsts; l->nconsts = nconsts;
l->next = _FcConstants; l->next = _FcConstants;
@ -200,6 +203,7 @@ FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
if (l->consts == consts && l->nconsts == nconsts) if (l->consts == consts && l->nconsts == nconsts)
{ {
*prev = l->next; *prev = l->next;
FcMemFree (FC_MEM_CONSTANT, sizeof (FcConstantList));
free ((void *) l); free ((void *) l);
return FcTrue; return FcTrue;
} }
@ -347,6 +351,7 @@ FcNameParse (const FcChar8 *name)
const FcObjectType *t; const FcObjectType *t;
const FcConstant *c; const FcConstant *c;
/* freed below */
save = malloc (strlen ((char *) name) + 1); save = malloc (strlen ((char *) name) + 1);
if (!save) if (!save)
goto bail0; goto bail0;

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.13 2002/08/11 18:10:42 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcpat.c,v 1.15 2002/08/22 07:36:45 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -482,6 +482,7 @@ FcPatternFreeze (FcPattern *p)
b = (FcPattern *) malloc (size); b = (FcPattern *) malloc (size);
if (!b) if (!b)
return 0; return 0;
FcMemAlloc (FC_MEM_PATTERN, size);
b->num = p->num; b->num = p->num;
b->size = b->num; b->size = b->num;
b->ref = 1; b->ref = 1;

View File

@ -341,6 +341,7 @@ FcStrBufDestroy (FcStrBuf *buf)
{ {
if (buf->allocated) if (buf->allocated)
{ {
FcMemFree (FC_MEM_STRBUF, buf->size);
free (buf->buf); free (buf->buf);
FcStrBufInit (buf, 0, 0); FcStrBufInit (buf, 0, 0);
} }
@ -354,6 +355,7 @@ FcStrBufDone (FcStrBuf *buf)
ret = malloc (buf->len + 1); ret = malloc (buf->len + 1);
if (ret) if (ret)
{ {
FcMemAlloc (FC_MEM_STRING, buf->len + 1);
memcpy (ret, buf->buf, buf->len); memcpy (ret, buf->buf, buf->len);
ret[buf->len] = '\0'; ret[buf->len] = '\0';
} }
@ -389,6 +391,9 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c)
buf->failed = FcTrue; buf->failed = FcTrue;
return FcFalse; return FcFalse;
} }
if (buf->size)
FcMemFree (FC_MEM_STRBUF, buf->size);
FcMemAlloc (FC_MEM_STRBUF, size);
buf->size = size; buf->size = size;
buf->buf = new; buf->buf = new;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.20 2002/08/20 23:17:03 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.21 2002/08/22 18:53:22 keithp Exp $
* *
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -46,6 +46,7 @@ FcTestCreate (FcMatchKind kind,
if (test) if (test)
{ {
FcMemAlloc (FC_MEM_TEST, sizeof (FcTest));
test->next = 0; test->next = 0;
test->kind = kind; test->kind = kind;
test->qual = qual; test->qual = qual;
@ -63,6 +64,7 @@ FcTestDestroy (FcTest *test)
FcTestDestroy (test->next); FcTestDestroy (test->next);
FcExprDestroy (test->expr); FcExprDestroy (test->expr);
FcStrFree ((FcChar8 *) test->field); FcStrFree ((FcChar8 *) test->field);
FcMemFree (FC_MEM_TEST, sizeof (FcTest));
free (test); free (test);
} }
@ -73,6 +75,7 @@ FcExprCreateInteger (int i)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpInteger; e->op = FcOpInteger;
e->u.ival = i; e->u.ival = i;
} }
@ -86,6 +89,7 @@ FcExprCreateDouble (double d)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpDouble; e->op = FcOpDouble;
e->u.dval = d; e->u.dval = d;
} }
@ -99,6 +103,7 @@ FcExprCreateString (const FcChar8 *s)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpString; e->op = FcOpString;
e->u.sval = FcStrCopy (s); e->u.sval = FcStrCopy (s);
} }
@ -112,6 +117,7 @@ FcExprCreateMatrix (const FcMatrix *m)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpMatrix; e->op = FcOpMatrix;
e->u.mval = FcMatrixCopy (m); e->u.mval = FcMatrixCopy (m);
} }
@ -125,6 +131,7 @@ FcExprCreateBool (FcBool b)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpBool; e->op = FcOpBool;
e->u.bval = b; e->u.bval = b;
} }
@ -138,6 +145,7 @@ FcExprCreateNil (void)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpNil; e->op = FcOpNil;
} }
return e; return e;
@ -150,6 +158,7 @@ FcExprCreateField (const char *field)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpField; e->op = FcOpField;
e->u.field = (char *) FcStrCopy ((FcChar8 *) field); e->u.field = (char *) FcStrCopy ((FcChar8 *) field);
} }
@ -163,6 +172,7 @@ FcExprCreateConst (const FcChar8 *constant)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = FcOpConst; e->op = FcOpConst;
e->u.constant = FcStrCopy (constant); e->u.constant = FcStrCopy (constant);
} }
@ -176,6 +186,7 @@ FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right)
if (e) if (e)
{ {
FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
e->op = op; e->op = op;
e->u.tree.left = left; e->u.tree.left = left;
e->u.tree.right = right; e->u.tree.right = right;
@ -240,6 +251,7 @@ FcExprDestroy (FcExpr *e)
case FcOpInvalid: case FcOpInvalid:
break; break;
} }
FcMemFree (FC_MEM_EXPR, sizeof (FcExpr));
free (e); free (e);
} }
@ -491,6 +503,7 @@ FcVStackCreate (void)
new = malloc (sizeof (FcVStack)); new = malloc (sizeof (FcVStack));
if (!new) if (!new)
return 0; return 0;
FcMemAlloc (FC_MEM_VSTACK, sizeof (FcVStack));
new->tag = FcVStackNone; new->tag = FcVStackNone;
new->prev = 0; new->prev = 0;
return new; return new;
@ -534,6 +547,7 @@ FcVStackDestroy (FcVStack *vstack)
FcEditDestroy (vstack->u.edit); FcEditDestroy (vstack->u.edit);
break; break;
} }
FcMemFree (FC_MEM_VSTACK, sizeof (FcVStack));
free (vstack); free (vstack);
} }
} }
@ -704,6 +718,7 @@ FcConfigSaveAttr (const XML_Char **attr)
new = malloc ((i + 1) * sizeof (FcChar8 *) + slen); new = malloc ((i + 1) * sizeof (FcChar8 *) + slen);
if (!new) if (!new)
return 0; return 0;
FcMemAlloc (FC_MEM_ATTR, 1); /* size is too expensive */
s = (FcChar8 *) (new + (i + 1)); s = (FcChar8 *) (new + (i + 1));
for (i = 0; attr[i]; i++) for (i = 0; attr[i]; i++)
{ {
@ -722,6 +737,7 @@ FcPStackPush (FcConfigParse *parse, FcElement element, const XML_Char **attr)
if (!new) if (!new)
return FcFalse; return FcFalse;
FcMemAlloc (FC_MEM_PSTACK, sizeof (FcPStack));
new->prev = parse->pstack; new->prev = parse->pstack;
new->element = element; new->element = element;
if (attr) if (attr)
@ -752,7 +768,11 @@ FcPStackPop (FcConfigParse *parse)
parse->pstack = old->prev; parse->pstack = old->prev;
FcStrBufDestroy (&old->str); FcStrBufDestroy (&old->str);
if (old->attr) if (old->attr)
{
FcMemFree (FC_MEM_ATTR, 1); /* size is to expensive */
free (old->attr); free (old->attr);
}
FcMemFree (FC_MEM_PSTACK, sizeof (FcPStack));
free (old); free (old);
return FcTrue; return FcTrue;
} }
@ -1317,7 +1337,7 @@ FcParseInclude (FcConfigParse *parse)
ignore_missing = FcTrue; ignore_missing = FcTrue;
if (!FcConfigParseAndLoad (parse->config, s, !ignore_missing)) if (!FcConfigParseAndLoad (parse->config, s, !ignore_missing))
parse->error = FcTrue; parse->error = FcTrue;
free (s); FcStrFree (s);
} }
typedef struct _FcOpMap { typedef struct _FcOpMap {
@ -1580,7 +1600,7 @@ FcEndElement(void *userData, const XML_Char *name)
} }
if (!FcConfigAddDir (parse->config, data)) if (!FcConfigAddDir (parse->config, data))
FcConfigMessage (parse, FcSevereError, "out of memory"); FcConfigMessage (parse, FcSevereError, "out of memory");
free (data); FcStrFree (data);
break; break;
case FcElementCache: case FcElementCache:
data = FcStrBufDone (&parse->pstack->str); data = FcStrBufDone (&parse->pstack->str);
@ -1591,7 +1611,7 @@ FcEndElement(void *userData, const XML_Char *name)
} }
if (!FcConfigSetCache (parse->config, data)) if (!FcConfigSetCache (parse->config, data))
FcConfigMessage (parse, FcSevereError, "out of memory"); FcConfigMessage (parse, FcSevereError, "out of memory");
free (data); FcStrFree (data);
break; break;
case FcElementInclude: case FcElementInclude:
FcParseInclude (parse); FcParseInclude (parse);
@ -1759,10 +1779,13 @@ FcConfigParseAndLoad (FcConfig *config,
goto bail0; goto bail0;
if (!FcStrSetAdd (config->configFiles, filename)) if (!FcStrSetAdd (config->configFiles, filename))
{
FcStrFree (filename);
goto bail0; goto bail0;
}
f = fopen ((char *) filename, "r"); f = fopen ((char *) filename, "r");
free (filename); FcStrFree (filename);
if (!f) if (!f)
goto bail0; goto bail0;