[Fontconfig] fontconfig: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Dec 29 20:13:23 PST 2012


 src/fcatomic.c  |    6 ---
 src/fcblanks.c  |    8 ----
 src/fccfg.c     |   16 --------
 src/fccharset.c |   36 -------------------
 src/fcfs.c      |    8 ----
 src/fcinit.c    |  105 --------------------------------------------------------
 src/fcint.h     |   45 ------------------------
 src/fclang.c    |   17 ---------
 src/fclist.c    |   10 -----
 src/fcmatrix.c  |    4 --
 src/fcname.c    |    2 -
 src/fcpat.c     |   20 ----------
 src/fcstr.c     |   21 -----------
 src/fcxml.c     |   22 -----------
 14 files changed, 2 insertions(+), 318 deletions(-)

New commits:
commit d7e1965aa0f55925913e9764d2d0792cc14490c2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Dec 29 23:12:07 2012 -0500

    Remove memory accounting and reporting
    
    That belongs in tools like cairo/util/malloc-stat.so

diff --git a/src/fcatomic.c b/src/fcatomic.c
index 350744a..b1dc30a 100644
--- a/src/fcatomic.c
+++ b/src/fcatomic.c
@@ -78,7 +78,6 @@ FcAtomicCreate (const FcChar8   *file)
     FcAtomic	*atomic = malloc (total_len);
     if (!atomic)
 	return 0;
-    FcMemAlloc (FC_MEM_ATOMIC, total_len);
 
     atomic->file = (FcChar8 *) (atomic + 1);
     strcpy ((char *) atomic->file, (char *) file);
@@ -223,11 +222,6 @@ FcAtomicUnlock (FcAtomic *atomic)
 void
 FcAtomicDestroy (FcAtomic *atomic)
 {
-    FcMemFree (FC_MEM_ATOMIC, sizeof (FcAtomic) +
-	       strlen ((char *) atomic->file) * 4 + 4 +
-	       sizeof (NEW_NAME) + sizeof (LCK_NAME) +
-	       sizeof (TMP_NAME));
-
     free (atomic);
 }
 #define __fcatomic__
diff --git a/src/fcblanks.c b/src/fcblanks.c
index a80a134..46698bc 100644
--- a/src/fcblanks.c
+++ b/src/fcblanks.c
@@ -32,7 +32,6 @@ FcBlanksCreate (void)
     b = malloc (sizeof (FcBlanks));
     if (!b)
 	return 0;
-    FcMemAlloc (FC_MEM_BLANKS, sizeof (FcBlanks));
     b->nblank = 0;
     b->sblank = 0;
     b->blanks = 0;
@@ -43,11 +42,7 @@ void
 FcBlanksDestroy (FcBlanks *b)
 {
     if (b->blanks)
-    {
-	FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32));
 	free (b->blanks);
-    }
-    FcMemFree (FC_MEM_BLANKS, sizeof (FcBlanks));
     free (b);
 }
 
@@ -70,9 +65,6 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
 	    c = (FcChar32 *) malloc (sblank * sizeof (FcChar32));
 	if (!c)
 	    return FcFalse;
-	if (b->sblank)
-	    FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32));
-	FcMemAlloc (FC_MEM_BLANKS, sblank * sizeof (FcChar32));
 	b->sblank = sblank;
 	b->blanks = c;
     }
diff --git a/src/fccfg.c b/src/fccfg.c
index f53be26..97345be 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -47,7 +47,6 @@ FcConfigCreate (void)
     config = malloc (sizeof (FcConfig));
     if (!config)
 	goto bail0;
-    FcMemAlloc (FC_MEM_CONFIG, sizeof (FcConfig));
 
     config->configDirs = FcStrSetCreate ();
     if (!config->configDirs)
@@ -115,7 +114,6 @@ bail2:
     FcStrSetDestroy (config->configDirs);
 bail1:
     free (config);
-    FcMemFree (FC_MEM_CONFIG, sizeof (FcConfig));
 bail0:
     return 0;
 }
@@ -190,7 +188,6 @@ FcSubstDestroy (FcSubst *s)
 	if (s->edit)
 	    FcEditDestroy (s->edit);
 	free (s);
-	FcMemFree (FC_MEM_SUBST, sizeof (FcSubst));
 	s = n;
     }
 }
@@ -205,7 +202,6 @@ FcConfigAllocExpr (FcConfig *config)
     new_page = malloc (sizeof (FcExprPage));
     if (!new_page)
       return 0;
-    FcMemAlloc (FC_MEM_EXPR, sizeof (FcExprPage));
 
     new_page->next_page = config->expr_pool;
     new_page->next = new_page->exprs;
@@ -265,13 +261,11 @@ FcConfigDestroy (FcConfig *config)
     while (page)
     {
       FcExprPage *next = page->next_page;
-      FcMemFree (FC_MEM_EXPR, sizeof (FcExprPage));
       free (page);
       page = next;
     }
 
     free (config);
-    FcMemFree (FC_MEM_CONFIG, sizeof (FcConfig));
 }
 
 /*
@@ -640,7 +634,6 @@ FcConfigAddEdit (FcConfig	*config,
     subst = (FcSubst *) malloc (sizeof (FcSubst));
     if (!subst)
 	return FcFalse;
-    FcMemAlloc (FC_MEM_SUBST, sizeof (FcSubst));
     for (; *prev; prev = &(*prev)->next);
     *prev = subst;
     subst->next = 0;
@@ -1054,7 +1047,6 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
 		    m = malloc (sizeof (FcMatrix));
 		    if (m)
 		    {
-			FcMemAlloc (FC_MEM_MATRIX, sizeof (FcMatrix));
 			FcMatrixMultiply (m, vl.u.m, vr.u.m);
 			v.u.m = m;
 		    }
@@ -1256,7 +1248,6 @@ FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
     l = (FcValueList *) malloc (sizeof (FcValueList));
     if (!l)
 	return 0;
-    FcMemAlloc (FC_MEM_VALLIST, sizeof (FcValueList));
     if (FC_OP_GET_OP (e->op) == FcOpComma)
     {
 	l->value = FcConfigEvaluate (p, e->u.tree.left);
@@ -1272,7 +1263,6 @@ FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
     {
 	FcValueList  *next = FcValueListNext(l);
 
-	FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
 	free (l);
 	l = next;
     }
@@ -1467,7 +1457,6 @@ FcConfigSubstituteWithPat (FcConfig    *config,
     st = (FcSubState *) malloc (config->maxObjects * sizeof (FcSubState));
     if (!st && config->maxObjects)
 	return FcFalse;
-    FcMemAlloc (FC_MEM_SUBSTATE, config->maxObjects * sizeof (FcSubState));
 
     if (FcDebug () & FC_DBG_EDIT)
     {
@@ -1653,7 +1642,6 @@ FcConfigSubstituteWithPat (FcConfig    *config,
 	    FcPatternPrint (p);
 	}
     }
-    FcMemFree (FC_MEM_SUBSTATE, config->maxObjects * sizeof (FcSubState));
     free (st);
     if (FcDebug () & FC_DBG_EDIT)
     {
@@ -1766,7 +1754,6 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
 #endif
     strcat ((char *) path, (char *) file);
 
-    FcMemAlloc (FC_MEM_STRING, osize);
     if (access ((char *) path, R_OK) == 0)
 	return path;
 
@@ -1891,7 +1878,6 @@ FcConfigXdgCacheHome (void)
 	ret = malloc (len + 7 + 1);
 	if (ret)
 	{
-	    FcMemAlloc (FC_MEM_STRING, len + 7 + 1);
 	    memcpy (ret, home, len);
 	    memcpy (&ret[len], FC_DIR_SEPARATOR_S ".cache", 7);
 	    ret[len + 7] = 0;
@@ -1917,7 +1903,6 @@ FcConfigXdgConfigHome (void)
 	ret = malloc (len + 8 + 1);
 	if (ret)
 	{
-	    FcMemAlloc (FC_MEM_STRING, len + 8 + 1);
 	    memcpy (ret, home, len);
 	    memcpy (&ret[len], FC_DIR_SEPARATOR_S ".config", 8);
 	    ret[len + 8] = 0;
@@ -1943,7 +1928,6 @@ FcConfigXdgDataHome (void)
 	ret = malloc (len + 13 + 1);
 	if (ret)
 	{
-	    FcMemAlloc (FC_MEM_STRING, len + 13 + 1);
 	    memcpy (ret, home, len);
 	    memcpy (&ret[len], FC_DIR_SEPARATOR_S ".local" FC_DIR_SEPARATOR_S "share", 13);
 	    ret[len + 13] = 0;
diff --git a/src/fccharset.c b/src/fccharset.c
index 61489c4..df98eb2 100644
--- a/src/fccharset.c
+++ b/src/fccharset.c
@@ -35,7 +35,6 @@ FcCharSetCreate (void)
     fcs = (FcCharSet *) malloc (sizeof (FcCharSet));
     if (!fcs)
 	return 0;
-    FcMemAlloc (FC_MEM_CHARSET, sizeof (FcCharSet));
     fcs->ref = 1;
     fcs->num = 0;
     fcs->leaves_offset = 0;
@@ -64,19 +63,12 @@ FcCharSetDestroy (FcCharSet *fcs)
 	if (--fcs->ref > 0)
 	    return;
 	for (i = 0; i < fcs->num; i++)
-	{
-	    FcMemFree (FC_MEM_CHARLEAF, sizeof (FcCharLeaf));
 	    free (FcCharSetLeaf (fcs, i));
-	}
 	if (fcs->num)
 	{
-	    /* the numbers here are estimates */
-	    FcMemFree (FC_MEM_CHARSET, fcs->num * sizeof (intptr_t));
 	    free (FcCharSetLeaves (fcs));
-	    FcMemFree (FC_MEM_CHARSET, fcs->num * sizeof (FcChar16));
 	    free (FcCharSetNumbers (fcs));
 	}
-	FcMemFree (FC_MEM_CHARSET, sizeof (FcCharSet));
 	free (fcs);
     }
 }
@@ -157,24 +149,16 @@ FcCharSetPutLeaf (FcCharSet	*fcs,
         unsigned int alloced = 8;
 	leaves = malloc (alloced * sizeof (*leaves));
 	numbers = malloc (alloced * sizeof (*numbers));
-	FcMemAlloc (FC_MEM_CHARSET, alloced * sizeof (*leaves));
-	FcMemAlloc (FC_MEM_CHARSET, alloced * sizeof (*numbers));
       }
       else
       {
         unsigned int alloced = fcs->num;
 	intptr_t *new_leaves, distance;
 
-	FcMemFree (FC_MEM_CHARSET, alloced * sizeof (*leaves));
-	FcMemFree (FC_MEM_CHARSET, alloced * sizeof (*numbers));
-
 	alloced *= 2;
 	new_leaves = realloc (leaves, alloced * sizeof (*leaves));
 	numbers = realloc (numbers, alloced * sizeof (*numbers));
 
-	FcMemAlloc (FC_MEM_CHARSET, alloced * sizeof (*leaves));
-	FcMemAlloc (FC_MEM_CHARSET, alloced * sizeof (*numbers));
-
 	distance = (intptr_t) new_leaves - (intptr_t) leaves;
 	if (new_leaves && distance)
 	{
@@ -227,7 +211,6 @@ FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4)
 	free (leaf);
 	return 0;
     }
-    FcMemAlloc (FC_MEM_CHARLEAF, sizeof (FcCharLeaf));
     return leaf;
 }
 
@@ -239,7 +222,6 @@ FcCharSetInsertLeaf (FcCharSet *fcs, FcChar32 ucs4, FcCharLeaf *leaf)
     pos = FcCharSetFindLeafPos (fcs, ucs4);
     if (pos >= 0)
     {
-	FcMemFree (FC_MEM_CHARLEAF, sizeof (FcCharLeaf));
 	free (FcCharSetLeaf (fcs, pos));
 	FcCharSetLeaves(fcs)[pos] = FcPtrToOffset (FcCharSetLeaves(fcs),
 						   leaf);
@@ -971,15 +953,12 @@ FcNameParseCharSet (FcChar8 *string)
 bail1:
     if (c->num)
     {
-	FcMemFree (FC_MEM_CHARSET, c->num * sizeof (FcCharLeaf *));
 	free (FcCharSetLeaves (c));
     }
     if (c->num)
     {
-	FcMemFree (FC_MEM_CHARSET, c->num * sizeof (FcChar16));
 	free (FcCharSetNumbers (c));
     }
-    FcMemFree (FC_MEM_CHARSET, sizeof (FcCharSet));
     free (c);
 bail0:
     return NULL;
@@ -1116,7 +1095,6 @@ FcCharLeafEntCreate (FcCharSetFreezer *freezer)
 	freezer->current_block = freezer->leaf_blocks[freezer->leaf_block_count-1] = malloc (FC_CHAR_LEAF_BLOCK * sizeof (FcCharLeafEnt));
 	if (!freezer->current_block)
 	    return 0;
-	FcMemAlloc (FC_MEM_CHARLEAF, FC_CHAR_LEAF_BLOCK * sizeof (FcCharLeafEnt));
 	freezer->leaf_remain = FC_CHAR_LEAF_BLOCK;
     }
     freezer->leaf_remain--;
@@ -1223,7 +1201,6 @@ FcCharSetFreezeBase (FcCharSetFreezer *freezer, FcCharSet *fcs)
     ent = malloc (size);
     if (!ent)
 	return 0;
-    FcMemAlloc (FC_MEM_CHARSET, size);
 
     freezer->charsets_allocated++;
 
@@ -1299,16 +1276,9 @@ FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs)
     freezer->leaves_seen += fcs->num;
 bail1:
     if (b->num)
-    {
-	FcMemFree (FC_MEM_CHARSET, b->num * sizeof (FcCharLeaf *));
 	free (FcCharSetLeaves (b));
-    }
     if (b->num)
-    {
-	FcMemFree (FC_MEM_CHARSET, b->num * sizeof (FcChar16));
 	free (FcCharSetNumbers (b));
-    }
-    FcMemFree (FC_MEM_CHARSET, sizeof (FcCharSet));
     free (b);
 bail0:
     return n;
@@ -1340,9 +1310,6 @@ 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);
 	}
     }
@@ -1358,10 +1325,7 @@ 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);
diff --git a/src/fcfs.c b/src/fcfs.c
index 6625687..941abba 100644
--- a/src/fcfs.c
+++ b/src/fcfs.c
@@ -33,7 +33,6 @@ FcFontSetCreate (void)
     s = (FcFontSet *) malloc (sizeof (FcFontSet));
     if (!s)
 	return 0;
-    FcMemAlloc (FC_MEM_FONTSET, sizeof (FcFontSet));
     s->nfont = 0;
     s->sfont = 0;
     s->fonts = 0;
@@ -48,11 +47,7 @@ FcFontSetDestroy (FcFontSet *s)
     for (i = 0; i < s->nfont; i++)
 	FcPatternDestroy (s->fonts[i]);
     if (s->fonts)
-    {
-	FcMemFree (FC_MEM_FONTPTR, s->sfont * sizeof (FcPattern *));
 	free (s->fonts);
-    }
-    FcMemFree (FC_MEM_FONTSET, sizeof (FcFontSet));
     free (s);
 }
 
@@ -71,9 +66,6 @@ FcFontSetAdd (FcFontSet *s, FcPattern *font)
 	    f = (FcPattern **) malloc (sfont * sizeof (FcPattern *));
 	if (!f)
 	    return FcFalse;
-	if (s->sfont)
-	    FcMemFree (FC_MEM_FONTPTR, s->sfont * sizeof (FcPattern *));
-	FcMemAlloc (FC_MEM_FONTPTR, sfont * sizeof (FcPattern *));
 	s->sfont = sfont;
 	s->fonts = f;
     }
diff --git a/src/fcinit.c b/src/fcinit.c
index 606483d..3a3c518 100644
--- a/src/fcinit.c
+++ b/src/fcinit.c
@@ -88,8 +88,6 @@ FcInitLoadConfig (void)
 	if (!p)
 	    goto bail;
 	prefix = p;
-	FcMemFree (FC_MEM_STRING, plen + 1);
-	FcMemAlloc (FC_MEM_STRING, plen + 12);
 	memcpy (&prefix[plen], FC_DIR_SEPARATOR_S "fontconfig", 11);
 	prefix[plen + 11] = 0;
 	fprintf (stderr,
@@ -145,8 +143,6 @@ FcInit (void)
     if (!config)
 	return FcFalse;
     FcConfigSetCurrent (config);
-    if (FcDebug() & FC_DBG_MEMORY)
-	FcMemReport ();
     return FcTrue;
 }
 
@@ -161,8 +157,6 @@ FcFini (void)
 
     FcObjectFini ();
     FcCacheFini ();
-    if (FcDebug() & FC_DBG_MEMORY)
-	FcMemReport ();
 }
 
 /*
@@ -205,105 +199,6 @@ FcInitBringUptoDate (void)
     return FcInitReinitialize ();
 }
 
-static struct {
-    char    name[16];
-    int	    alloc_count;
-    int	    alloc_mem;
-    int	    free_count;
-    int	    free_mem;
-} FcInUse[FC_MEM_NUM] = {
-    { "charset" },
-    { "charleaf" },
-    { "fontset" },
-    { "fontptr" },
-    { "objectset" },
-    { "objectptr" },
-    { "matrix" },
-    { "pattern" },
-    { "patelt" },
-    { "vallist" },
-    { "substate" },
-    { "string" },
-    { "listbuck" },
-    { "strset" },
-    { "strlist" },
-    { "config" },
-    { "langset" },
-    { "atomic" },
-    { "blanks" },
-    { "cache" },
-    { "strbuf" },
-    { "subst" },
-    { "objecttype" },
-    { "constant" },
-    { "test" },
-    { "expr" },
-    { "vstack" },
-    { "attr" },
-    { "pstack" },
-    { "sharedstr" },
-};
-
-static int  FcAllocCount, FcAllocMem;
-static int  FcFreeCount, FcFreeMem;
-
-static int  FcMemNotice = 1*1024*1024;
-
-static int  FcAllocNotify, FcFreeNotify;
-
-void
-FcMemReport (void)
-{
-    int	i;
-    printf ("Fc Memory Usage:\n");
-    printf ("\t   Which       Alloc           Free           Active\n");
-    printf ("\t           count   bytes   count   bytes   count   bytes\n");
-    for (i = 0; i < FC_MEM_NUM; i++)
-	printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
-		FcInUse[i].name,
-		FcInUse[i].alloc_count, FcInUse[i].alloc_mem,
-		FcInUse[i].free_count, FcInUse[i].free_mem,
-		FcInUse[i].alloc_count - FcInUse[i].free_count,
-		FcInUse[i].alloc_mem - FcInUse[i].free_mem);
-    printf ("%16.16s%8d%8d%8d%8d%8d%8d\n",
-	    "Total",
-	    FcAllocCount, FcAllocMem,
-	    FcFreeCount, FcFreeMem,
-	    FcAllocCount - FcFreeCount,
-	    FcAllocMem - FcFreeMem);
-    FcAllocNotify = 0;
-    FcFreeNotify = 0;
-}
-
-void
-FcMemAlloc (int kind, int size)
-{
-    if (FcDebug() & FC_DBG_MEMORY)
-    {
-	FcInUse[kind].alloc_count++;
-	FcInUse[kind].alloc_mem += size;
-	FcAllocCount++;
-	FcAllocMem += size;
-	FcAllocNotify += size;
-	if (FcAllocNotify > FcMemNotice)
-	    FcMemReport ();
-    }
-}
-
-void
-FcMemFree (int kind, int size)
-{
-    if (FcDebug() & FC_DBG_MEMORY)
-    {
-	FcInUse[kind].free_count++;
-	FcInUse[kind].free_mem += size;
-	FcFreeCount++;
-	FcFreeMem += size;
-	FcFreeNotify += size;
-	if (FcFreeNotify > FcMemNotice)
-	    FcMemReport ();
-    }
-}
 #define __fcinit__
 #include "fcaliastail.h"
 #undef __fcinit__
diff --git a/src/fcint.h b/src/fcint.h
index 8b5a104..652f52d 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -84,44 +84,10 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #define FC_DBG_PARSE	64
 #define FC_DBG_SCAN	128
 #define FC_DBG_SCANV	256
-#define FC_DBG_MEMORY	512
 #define FC_DBG_CONFIG	1024
 #define FC_DBG_LANGSET	2048
 #define FC_DBG_OBJTYPES	4096
 
-#define FC_MEM_CHARSET	    0
-#define FC_MEM_CHARLEAF	    1
-#define FC_MEM_FONTSET	    2
-#define FC_MEM_FONTPTR	    3
-#define FC_MEM_OBJECTSET    4
-#define FC_MEM_OBJECTPTR    5
-#define FC_MEM_MATRIX	    6
-#define FC_MEM_PATTERN	    7
-#define FC_MEM_PATELT	    8
-#define FC_MEM_VALLIST	    9
-#define FC_MEM_SUBSTATE	    10
-#define FC_MEM_STRING	    11
-#define FC_MEM_LISTBUCK	    12
-#define FC_MEM_STRSET	    13
-#define FC_MEM_STRLIST	    14
-#define FC_MEM_CONFIG	    15
-#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_SHAREDSTR    29
-
-#define FC_MEM_NUM	    30
-
 #define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
 #define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
 #define FC_ASSERT_STATIC(_cond) _FC_ASSERT_STATIC0 (__LINE__, (_cond))
@@ -810,17 +776,6 @@ FcTestDestroy (FcTest *test);
 FcPrivate void
 FcEditDestroy (FcEdit *e);
 
-/* fcinit.c */
-
-FcPrivate void
-FcMemReport (void);
-
-FcPrivate void
-FcMemAlloc (int kind, int size);
-
-FcPrivate void
-FcMemFree (int kind, int size);
-
 /* fclang.c */
 FcPrivate FcLangSet *
 FcFreeTypeLangSet (const FcCharSet  *charset,
diff --git a/src/fclang.c b/src/fclang.c
index 57183fd..d1fadf5 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -182,7 +182,7 @@ FcLangNormalize (const FcChar8 *lang)
 {
     FcChar8 *result = NULL, *s, *orig;
     char *territory, *encoding, *modifier;
-    size_t llen, tlen = 0, mlen = 0, ssize;
+    size_t llen, tlen = 0, mlen = 0;
 
     if (!lang || !*lang)
 	return NULL;
@@ -197,10 +197,6 @@ FcLangNormalize (const FcChar8 *lang)
     s = FcStrCopy (lang);
     if (!s)
 	goto bail;
-    /* store the original length of 's' here to let FcMemFree know
-     * the correct size since we breaks 's' from now on.
-     */
-    ssize = strlen ((const char *)s) + 1;
 
     /* from the comments in glibc:
      *
@@ -289,8 +285,6 @@ FcLangNormalize (const FcChar8 *lang)
 	    /* we'll miss the opportunity to reduce the correct size
 	     * of the allocated memory for the string after that.
 	     */
-	    FcMemFree (FC_MEM_STRING, ssize);
-	    FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1);
 	    s = NULL;
 	    goto bail1;
 	}
@@ -307,8 +301,6 @@ FcLangNormalize (const FcChar8 *lang)
 	    /* we'll miss the opportunity to reduce the correct size
 	     * of the allocated memory for the string after that.
 	     */
-	    FcMemFree (FC_MEM_STRING, ssize);
-	    FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1);
 	    s = NULL;
 	    goto bail1;
 	}
@@ -329,8 +321,6 @@ FcLangNormalize (const FcChar8 *lang)
 	/* we'll miss the opportunity to reduce the correct size
 	 * of the allocated memory for the string after that.
 	 */
-	FcMemFree (FC_MEM_STRING, ssize);
-	FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1);
 	s = NULL;
     }
   bail1:
@@ -338,10 +328,7 @@ FcLangNormalize (const FcChar8 *lang)
 	FcStrFree (orig);
   bail0:
     if (s)
-    {
 	free (s);
-	FcMemFree (FC_MEM_STRING, ssize);
-    }
   bail:
     if (FcDebug () & FC_DBG_LANGSET)
     {
@@ -465,7 +452,6 @@ FcLangSetCreate (void)
     ls = malloc (sizeof (FcLangSet));
     if (!ls)
 	return 0;
-    FcMemAlloc (FC_MEM_LANGSET, sizeof (FcLangSet));
     memset (ls->map, '\0', sizeof (ls->map));
     ls->map_size = NUM_LANG_SET_MAP;
     ls->extra = 0;
@@ -477,7 +463,6 @@ FcLangSetDestroy (FcLangSet *ls)
 {
     if (ls->extra)
 	FcStrSetDestroy (ls->extra);
-    FcMemFree (FC_MEM_LANGSET, sizeof (FcLangSet));
     free (ls);
 }
 
diff --git a/src/fclist.c b/src/fclist.c
index 56f0432..ba68d68 100644
--- a/src/fclist.c
+++ b/src/fclist.c
@@ -33,7 +33,6 @@ FcObjectSetCreate (void)
     os = (FcObjectSet *) malloc (sizeof (FcObjectSet));
     if (!os)
 	return 0;
-    FcMemAlloc (FC_MEM_OBJECTSET, sizeof (FcObjectSet));
     os->nobject = 0;
     os->sobject = 0;
     os->objects = 0;
@@ -57,9 +56,6 @@ FcObjectSetAdd (FcObjectSet *os, const char *object)
 	    objects = (const char **) malloc (s * sizeof (const char *));
 	if (!objects)
 	    return FcFalse;
-	if (os->sobject)
-	    FcMemFree (FC_MEM_OBJECTPTR, os->sobject * sizeof (const char *));
-	FcMemAlloc (FC_MEM_OBJECTPTR, s * sizeof (const char *));
 	os->objects = objects;
 	os->sobject = s;
     }
@@ -101,10 +97,8 @@ FcObjectSetDestroy (FcObjectSet *os)
 	for (i = 0; i < os->nobject; i++)
 	    FcSharedStrFree ((FcChar8 *)os->objects[i]);
 
-	FcMemFree (FC_MEM_OBJECTPTR, os->sobject * sizeof (const char *));
 	free ((void *) os->objects);
     }
-    FcMemFree (FC_MEM_OBJECTSET, sizeof (FcObjectSet));
     free (os);
 }
 
@@ -342,7 +336,6 @@ FcListHashTableCleanup (FcListHashTable *table)
 	{
 	    next = bucket->next;
 	    FcPatternDestroy (bucket->pattern);
-	    FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
 	    free (bucket);
 	}
 	table->buckets[i] = 0;
@@ -418,7 +411,6 @@ FcListAppend (FcListHashTable	*table,
     bucket = (FcListBucket *) malloc (sizeof (FcListBucket));
     if (!bucket)
 	goto bail0;
-    FcMemAlloc (FC_MEM_LISTBUCK, sizeof (FcListBucket));
     bucket->next = 0;
     bucket->hash = hash;
     bucket->pattern = FcPatternCreate ();
@@ -469,7 +461,6 @@ FcListAppend (FcListHashTable	*table,
 bail2:
     FcPatternDestroy (bucket->pattern);
 bail1:
-    FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
     free (bucket);
 bail0:
     return FcFalse;
@@ -569,7 +560,6 @@ FcFontSetList (FcConfig	    *config,
 	    if (!FcFontSetAdd (ret, bucket->pattern))
 		goto bail2;
 	    table.buckets[i] = bucket->next;
-	    FcMemFree (FC_MEM_LISTBUCK, sizeof (FcListBucket));
 	    free (bucket);
 	}
 
diff --git a/src/fcmatrix.c b/src/fcmatrix.c
index f0c6139..a6fbca2 100644
--- a/src/fcmatrix.c
+++ b/src/fcmatrix.c
@@ -38,7 +38,6 @@ FcMatrixCopy (const FcMatrix *mat)
     r = (FcMatrix *) malloc (sizeof (*r) );
     if (!r)
 	return 0;
-    FcMemAlloc (FC_MEM_MATRIX, sizeof (FcMatrix));
     *r = *mat;
     return r;
 }
@@ -47,10 +46,7 @@ void
 FcMatrixFree (FcMatrix *mat)
 {
     if (mat != &FcIdentityMatrix)
-    {
-	FcMemFree (FC_MEM_MATRIX, sizeof (FcMatrix));
 	free (mat);
-    }
 }
 
 FcBool
diff --git a/src/fcname.c b/src/fcname.c
index 5540b6f..b7c0217 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -481,7 +481,6 @@ FcNameRegisterConstants (const FcConstant *consts, int nconsts)
     l = (FcConstantList *) malloc (sizeof (FcConstantList));
     if (!l)
 	return FcFalse;
-    FcMemAlloc (FC_MEM_CONSTANT, sizeof (FcConstantList));
     l->consts = consts;
     l->nconsts = nconsts;
     l->next = _FcConstants;
@@ -501,7 +500,6 @@ FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
 	if (l->consts == consts && l->nconsts == nconsts)
 	{
 	    *prev = l->next;
-	    FcMemFree (FC_MEM_CONSTANT, sizeof (FcConstantList));
 	    free ((void *) l);
 	    return FcTrue;
 	}
diff --git a/src/fcpat.c b/src/fcpat.c
index fe43d3a..5d94295 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -34,7 +34,6 @@ FcPatternCreate (void)
     p = (FcPattern *) malloc (sizeof (FcPattern));
     if (!p)
 	return 0;
-    FcMemAlloc (FC_MEM_PATTERN, sizeof (FcPattern));
     p->num = 0;
     p->size = 0;
     p->elts_offset = FcPtrToOffset (p, NULL);
@@ -123,15 +122,7 @@ FcValueSave (FcValue v)
 FcValueListPtr
 FcValueListCreate (void)
 {
-    FcValueListPtr ret;
-
-    ret = calloc (1, sizeof (FcValueList));
-    if (ret)
-    {
-	FcMemAlloc(FC_MEM_VALLIST, sizeof (FcValueList));
-    }
-
-    return ret;
+    return calloc (1, sizeof (FcValueList));
 }
 
 void
@@ -160,7 +151,6 @@ FcValueListDestroy (FcValueListPtr l)
 	    break;
 	}
 	next = FcValueListNext(l);
-	FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
 	free(l);
     }
 }
@@ -382,9 +372,7 @@ FcPatternDestroy (FcPattern *p)
     for (i = 0; i < p->num; i++)
 	FcValueListDestroy (FcPatternEltValues(&elts[i]));
 
-    FcMemFree (FC_MEM_PATELT, p->size * sizeof (FcPatternElt));
     free (elts);
-    FcMemFree (FC_MEM_PATTERN, sizeof (FcPattern));
     free (p);
 }
 
@@ -454,9 +442,6 @@ FcPatternObjectInsertElt (FcPattern *p, FcObject object)
 	    if (!e)
 		return FcFalse;
 	    p->elts_offset = FcPtrToOffset (p, e);
-	    if (p->size)
-		FcMemFree (FC_MEM_PATELT, p->size * sizeof (FcPatternElt));
-	    FcMemAlloc (FC_MEM_PATELT, s * sizeof (FcPatternElt));
 	    while (p->size < s)
 	    {
 		e[p->size].object = 0;
@@ -662,7 +647,6 @@ FcPatternObjectAddWithBinding  (FcPattern	*p,
 bail2:
     FcValueDestroy (value);
 bail1:
-    FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList));
     free (new);
 bail0:
     return FcFalse;
@@ -1187,7 +1171,6 @@ FcSharedStrFree (const FcChar8 *name)
 		*p = b->next;
 		size = sizeof (struct objectBucket) + strlen ((char *)name) + 1;
 		size = (size + 3) & ~3;
-		FcMemFree (FC_MEM_SHAREDSTR, size);
 		free (b);
 	    }
             return FcTrue;
@@ -1216,7 +1199,6 @@ FcSharedStr (const FcChar8 *name)
      */
     size = (size + 3) & ~3;
     b = malloc (size);
-    FcMemAlloc (FC_MEM_SHAREDSTR, size);
     if (!b)
         return NULL;
     b->next = 0;
diff --git a/src/fcstr.c b/src/fcstr.c
index 062c5d1..553588f 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -44,7 +44,6 @@ FcStrCopy (const FcChar8 *s)
     r = (FcChar8 *) malloc (len);
     if (!r)
 	return 0;
-    FcMemAlloc (FC_MEM_STRING, len);
     memcpy (r, s, len);
     return r;
 }
@@ -59,7 +58,6 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2)
 
     if (!s)
 	return 0;
-    FcMemAlloc (FC_MEM_STRING, l);
     memcpy (s, s1, s1l);
     memcpy (s + s1l, s2, s2l + 1);
     return s;
@@ -68,7 +66,6 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2)
 void
 FcStrFree (FcChar8 *s)
 {
-    FcMemFree (FC_MEM_STRING, strlen ((char *) s) + 1);
     free (s);
 }
 
@@ -204,7 +201,6 @@ FcStrDowncase (const FcChar8 *s)
     d = dst = malloc (len + 1);
     if (!d)
 	return 0;
-    FcMemAlloc (FC_MEM_STRING, len + 1);
     FcStrCaseWalkerInit (s, &w);
     while ((*d++ = FcStrCaseWalkerNext (&w)));
     return dst;
@@ -780,7 +776,6 @@ FcStrBufDestroy (FcStrBuf *buf)
 {
     if (buf->allocated)
     {
-	FcMemFree (FC_MEM_STRBUF, buf->size);
 	free (buf->buf);
 	FcStrBufInit (buf, 0, 0);
     }
@@ -797,7 +792,6 @@ FcStrBufDone (FcStrBuf *buf)
 	ret = malloc (buf->len + 1);
     if (ret)
     {
-	FcMemAlloc (FC_MEM_STRING, buf->len + 1);
 	memcpy (ret, buf->buf, buf->len);
 	ret[buf->len] = '\0';
     }
@@ -830,7 +824,6 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c)
 	if (buf->allocated)
 	{
 	    size = buf->size * 2;
-	    FcMemFree (FC_MEM_STRBUF, buf->size);
 	    new = realloc (buf->buf, size);
 	}
 	else
@@ -848,7 +841,6 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c)
 	    buf->failed = FcTrue;
 	    return FcFalse;
 	}
-	FcMemAlloc (FC_MEM_STRBUF, size);
 	buf->size = size;
 	buf->buf = new;
     }
@@ -939,7 +931,6 @@ FcStrDirname (const FcChar8 *file)
     dir = malloc ((slash - file) + 1);
     if (!dir)
 	return 0;
-    FcMemAlloc (FC_MEM_STRING, (slash - file) + 1);
     strncpy ((char *) dir, (const char *) file, slash - file);
     dir[slash - file] = '\0';
     return dir;
@@ -968,7 +959,6 @@ FcStrCanonAbsoluteFilename (const FcChar8 *s)
     file = malloc (size);
     if (!file)
 	return NULL;
-    FcMemAlloc (FC_MEM_STRING, size);
     slash = NULL;
     f = file;
 #ifdef _WIN32
@@ -1088,7 +1078,6 @@ FcStrSetCreate (void)
     FcStrSet	*set = malloc (sizeof (FcStrSet));
     if (!set)
 	return 0;
-    FcMemAlloc (FC_MEM_STRSET, sizeof (FcStrSet));
     set->ref = 1;
     set->num = 0;
     set->size = 0;
@@ -1110,14 +1099,10 @@ _FcStrSetAppend (FcStrSet *set, FcChar8 *s)
 
 	if (!strs)
 	    return FcFalse;
-	FcMemAlloc (FC_MEM_STRSET, (set->size + 2) * sizeof (FcChar8 *));
 	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;
     }
@@ -1252,11 +1237,7 @@ FcStrSetDestroy (FcStrSet *set)
 	for (i = 0; i < set->num; i++)
 	    FcStrFree (set->strs[i]);
 	if (set->strs)
-	{
-	    FcMemFree (FC_MEM_STRSET, (set->size + 1) * sizeof (FcChar8 *));
 	    free (set->strs);
-	}
-	FcMemFree (FC_MEM_STRSET, sizeof (FcStrSet));
 	free (set);
     }
 }
@@ -1269,7 +1250,6 @@ FcStrListCreate (FcStrSet *set)
     list = malloc (sizeof (FcStrList));
     if (!list)
 	return 0;
-    FcMemAlloc (FC_MEM_STRLIST, sizeof (FcStrList));
     list->set = set;
     set->ref++;
     list->n = 0;
@@ -1288,7 +1268,6 @@ void
 FcStrListDone (FcStrList *list)
 {
     FcStrSetDestroy (list->set);
-    FcMemFree (FC_MEM_STRLIST, sizeof (FcStrList));
     free (list);
 }
 
diff --git a/src/fcxml.c b/src/fcxml.c
index 47a327e..21666d0 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -65,7 +65,6 @@ FcTestDestroy (FcTest *test)
     if (test->next)
 	FcTestDestroy (test->next);
     FcExprDestroy (test->expr);
-    FcMemFree (FC_MEM_TEST, sizeof (FcTest));
     free (test);
 }
 
@@ -708,7 +707,6 @@ FcTestCreate (FcConfigParse *parse,
     {
 	const FcObjectType	*o;
 	
-	FcMemAlloc (FC_MEM_TEST, sizeof (FcTest));
 	test->next = 0;
 	test->kind = kind;
 	test->qual = qual;
@@ -759,7 +757,6 @@ FcVStackCreateAndPush (FcConfigParse *parse)
 	new = malloc (sizeof (FcVStack));
 	if (!new)
 	    return 0;
-	FcMemAlloc (FC_MEM_VSTACK, sizeof (FcVStack));
     }
     new->tag = FcVStackNone;
     new->prev = 0;
@@ -984,10 +981,7 @@ FcVStackPopAndDestroy (FcConfigParse *parse)
     if (vstack == &parse->vstack_static[parse->vstack_static_used - 1])
 	parse->vstack_static_used--;
     else
-    {
-	FcMemFree (FC_MEM_VSTACK, sizeof (FcVStack));
 	free (vstack);
-    }
 }
 
 static void
@@ -1036,7 +1030,6 @@ FcConfigSaveAttr (const XML_Char **attr, FcChar8 **buf, int size_bytes)
 	    FcConfigMessage (0, FcSevereError, "out of memory");
 	    return 0;
 	}
-	FcMemAlloc (FC_MEM_ATTR, 1);    /* size is too expensive */
     }
     s = (FcChar8 *) (new + (i + 1));
     for (i = 0; attr[i]; i++)
@@ -1061,7 +1054,6 @@ FcPStackPush (FcConfigParse *parse, FcElement element, const XML_Char **attr)
 	new = malloc (sizeof (FcPStack));
 	if (!new)
 	    return FcFalse;
-	FcMemAlloc (FC_MEM_PSTACK, sizeof (FcPStack));
     }
 
     new->prev = parse->pstack;
@@ -1087,18 +1079,12 @@ FcPStackPop (FcConfigParse *parse)
     parse->pstack = old->prev;
     FcStrBufDestroy (&old->str);
     if (old->attr && old->attr != old->attr_buf_static)
-    {
-	FcMemFree (FC_MEM_ATTR, 1); /* size is to expensive */
 	free (old->attr);
-    }
 
     if (old == &parse->pstack_static[parse->pstack_static_used - 1])
 	parse->pstack_static_used--;
     else
-    {
-	FcMemFree (FC_MEM_PSTACK, sizeof (FcPStack));
 	free (old);
-    }
     return FcTrue;
 }
 
@@ -1889,8 +1875,6 @@ FcParseDir (FcConfigParse *parse)
 	    goto bail;
 	}
 	prefix = p;
-	FcMemFree (FC_MEM_STRING, plen + 1);
-	FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1);
 	prefix[plen] = FC_DIR_SEPARATOR;
 	memcpy (&prefix[plen + 1], data, dlen);
 	prefix[plen + 1 + dlen] = 0;
@@ -1986,8 +1970,6 @@ FcParseCacheDir (FcConfigParse *parse)
 	    goto bail;
 	}
 	prefix = p;
-	FcMemFree (FC_MEM_STRING, plen + 1);
-	FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1);
 	prefix[plen] = FC_DIR_SEPARATOR;
 	memcpy (&prefix[plen + 1], data, dlen);
 	prefix[plen + 1 + dlen] = 0;
@@ -2005,7 +1987,6 @@ FcParseCacheDir (FcConfigParse *parse)
 	    FcConfigMessage (parse, FcSevereError, "out of memory");
 	    goto bail;
 	}
-	FcMemAlloc (FC_MEM_STRING, 1000);
 	rc = GetTempPath (800, (LPSTR) data);
 	if (rc == 0 || rc > 800)
 	{
@@ -2035,7 +2016,6 @@ FcParseCacheDir (FcConfigParse *parse)
 	    FcConfigMessage (parse, FcSevereError, "out of memory");
 	    goto bail;
 	}
-	FcMemAlloc (FC_MEM_STRING, len);
 	strncpy((char *) data, szFPath, len);
     }
 #endif
@@ -2089,8 +2069,6 @@ FcParseInclude (FcConfigParse *parse)
 	    goto bail;
 	}
 	prefix = p;
-	FcMemFree (FC_MEM_STRING, plen + 1);
-	FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1);
 	prefix[plen] = FC_DIR_SEPARATOR;
 	memcpy (&prefix[plen + 1], s, dlen);
 	prefix[plen + 1 + dlen] = 0;


More information about the Fontconfig mailing list