]> git.wh0rd.org - fontconfig.git/commitdiff
More complete memory tracking. Install always overwrites header files
authorKeith Packard <keithp@keithp.com>
Sat, 31 Aug 2002 22:17:32 +0000 (22:17 +0000)
committerKeith Packard <keithp@keithp.com>
Sat, 31 Aug 2002 22:17:32 +0000 (22:17 +0000)
15 files changed:
fontconfig/Makefile.in
src/fcatomic.c
src/fcblanks.c
src/fccache.c
src/fccfg.c
src/fccharset.c
src/fcdir.c
src/fcfreetype.c
src/fcinit.c
src/fcint.h
src/fcmatch.c
src/fcname.c
src/fcpat.c
src/fcstr.c
src/fcxml.c

index a84d4b2278c3bab427d62cac2c7d68615c41fb4c..cd91053adc56a6e493a006f9f390f2434415f816 100644 (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.
 #
@@ -29,20 +29,11 @@ include $(TOPDIR)/config/Makedefs
 all::
 
 install:: $(DESTDIR)$(INCLUDEDIR)
-install:: $(DESTDIR)$(INCLUDEDIR)/fcfreetype.h
-install:: $(DESTDIR)$(INCLUDEDIR)/fcprivate.h
-install:: $(DESTDIR)$(INCLUDEDIR)/fontconfig.h
+       $(INSTALL_DATA) fcfreetype.h $(DESTDIR)$(INCLUDEDIR)/fcfreetype.h
+       $(INSTALL_DATA) fcprivate.h $(DESTDIR)$(INCLUDEDIR)/fcprivate.h
+       $(INSTALL_DATA) fontconfig.h $(DESTDIR)$(INCLUDEDIR)/fontconfig.h
 
 $(DESTDIR)$(INCLUDEDIR):
        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::
index 68acde31177fa20f67eb7579175d91f1e332428d..49b278ea59b699e3501178aadf653b7dd9e802d4 100644 (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.
  *
@@ -70,6 +70,7 @@ 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);
@@ -179,5 +180,10 @@ FcAtomicUnlock (FcAtomic *atomic)
 void
 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);
 }
index 8b3a9a926b16fefaf6d2438b0050631bb5ab7f0f..887c20328859ef2b0598b0496bd193b588ada7c3 100644 (file)
@@ -32,6 +32,7 @@ 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;
@@ -42,7 +43,11 @@ 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);
 }
 
@@ -65,6 +70,9 @@ 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;
     }
index 0ff2721b22e88b5c92f32430a4a0cbf73a937ea8..3bf0de9c3fcfb4c0066058c602d99c6eecb482e9 100644 (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.
  *
@@ -77,7 +77,7 @@ FcCacheReadString (FILE *f, FcChar8 *dest, int len)
        }
        if (i == size)
        {
-           FcChar8 *new = malloc (size * 2);
+           FcChar8 *new = malloc (size * 2);   /* freed in caller */
            if (!new)
                break;
            memcpy (new, d, size);
@@ -253,7 +253,7 @@ FcCacheFontSetAdd (FcFontSet            *set,
     len = (dir_len + 1 + strlen ((const char *) file) + 1);
     if (len > sizeof (path_buf))
     {
-       path = malloc (len);
+       path = malloc (len);    /* freed down below */
        if (!path)
            return FcFalse;
     }
@@ -406,6 +406,7 @@ FcGlobalCacheDirGet (FcGlobalCache  *cache,
        d = malloc (sizeof (FcGlobalCacheDir) + len + 1);
        if (!d)
            return 0;
+       FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCacheDir) + len + 1);
        d->next = *prev;
        *prev = d;
        d->info.hash = hash;
@@ -451,6 +452,8 @@ FcGlobalCacheDirAdd (FcGlobalCache  *cache,
                     strlen ((const char *) i.base) + 1);
     if (!subdir)
        return 0;
+    FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir) +
+               strlen ((const char *) i.base) + 1);
     subdir->file = (FcChar8 *) (subdir + 1);
     strcpy ((char *) subdir->file, (const char *) i.base);
     subdir->next = parent->subdirs;
@@ -469,13 +472,19 @@ FcGlobalCacheDirDestroy (FcGlobalCacheDir *d)
        for (f = d->ents[h]; f; f = next)
        {
            next = f->next;
+           FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheFile) +
+                      strlen ((char *) f->info.file) + 1 +
+                      strlen ((char *) f->name) + 1);
            free (f);
        }
     for (s = d->subdirs; s; s = nexts)
     {
        nexts = s->next;
+       FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheSubdir) +
+                  strlen ((char *) s->file) + 1);
        free (s);
     }
+    FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheDir) + d->len + 1);
     free (d);
 }
 
@@ -587,6 +596,7 @@ FcGlobalCacheFileAdd (FcGlobalCache *cache,
     FcGlobalCacheDir   *d = FcGlobalCacheDirGet (cache, i.dir, 
                                                  i.dir_len, FcTrue);
     FcGlobalCacheFile  *f, **prev;
+    int                        size;
 
     if (!d)
        return 0;
@@ -610,13 +620,18 @@ FcGlobalCacheFileAdd (FcGlobalCache *cache,
        if (f->info.referenced)
            cache->referenced--;
        *prev = f->next;
+       FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCacheFile) +
+                  strlen ((char *) f->info.file) + 1 +
+                  strlen ((char *) f->name) + 1);
        free (f);
     }
-    f = malloc (sizeof (FcGlobalCacheFile) +
-               strlen ((char *) i.base) + 1 +
-               strlen ((char *) name) + 1);
+    size = (sizeof (FcGlobalCacheFile) +
+           strlen ((char *) i.base) + 1 +
+           strlen ((char *) name) + 1);
+    f = malloc (size);
     if (!f)
        return 0;
+    FcMemAlloc (FC_MEM_CACHE, size);
     f->next = *prev;
     *prev = f;
     f->info.hash = i.base_hash;
@@ -639,6 +654,7 @@ FcGlobalCacheCreate (void)
     cache = malloc (sizeof (FcGlobalCache));
     if (!cache)
        return 0;
+    FcMemAlloc (FC_MEM_CACHE, sizeof (FcGlobalCache));
     for (h = 0; h < FC_GLOBAL_CACHE_DIR_HASH_SIZE; h++)
        cache->ents[h] = 0;
     cache->entries = 0;
@@ -662,6 +678,7 @@ FcGlobalCacheDestroy (FcGlobalCache *cache)
            FcGlobalCacheDirDestroy (d);
        }
     }
+    FcMemFree (FC_MEM_CACHE, sizeof (FcGlobalCache));
     free (cache);
 }
 
@@ -946,7 +963,7 @@ bail3:
 bail2:
     fclose (f);
 bail1:
-    free (cache_file);
+    FcStrFree (cache_file);
 bail0:
     return ret;
 }
@@ -1036,7 +1053,7 @@ FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
        if (!name)
            goto bail3;
        ret = FcCacheWriteString (f, name);
-       free (name);
+       FcStrFree (name);
        if (!ret)
            goto bail3;
        if (PUTC ('\n', f) == EOF)
@@ -1048,7 +1065,7 @@ FcDirCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
     if (fclose (f) == EOF)
        goto bail1;
     
-    free (cache_file);
+    FcStrFree (cache_file);
 
     if (FcDebug () & FC_DBG_CACHE)
        printf (" cache written\n");
@@ -1060,7 +1077,7 @@ bail2:
     fclose (f);
 bail1:
     unlink ((char *) cache_file);
-    free (cache_file);
+    FcStrFree (cache_file);
 bail0:
     return FcFalse;
 }
index 3e9874d8ff2770c081091dd426ad88f8742cfa30..8442f80a7322b36e9fcc58fa63e21473760411e5 100644 (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.
  *
@@ -429,6 +429,7 @@ FcConfigAddEdit (FcConfig   *config,
     subst = (FcSubst *) malloc (sizeof (FcSubst));
     if (!subst)
        return FcFalse;
+    FcMemAlloc (FC_MEM_SUBST, sizeof (FcSubst));
     if (kind == FcMatchPattern)
        prev = &config->substPattern;
     else
@@ -1274,10 +1275,11 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
        strcat ((char *) path, "/");
     strcat ((char *) path, (char *) file);
 
+    FcMemAlloc (FC_MEM_STRING, strlen ((char *) path) + 1);
     if (access ((char *) path, R_OK) == 0)
        return path;
     
-    free (path);
+    FcStrFree (path);
     return 0;
 }
 
index 22fde8ed8e079a7d0fd225bfb55e6a3994570fcc..c7d86706606a6102f286e4f776063c216a3ef9da 100644 (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.
  *
@@ -142,7 +142,9 @@ FcCharSetPutLeaf (FcCharSet *fcs,
        leaves = realloc (fcs->leaves, (fcs->num + 1) * sizeof (FcCharLeaf *));
     if (!leaves)
        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;
     if (!fcs->numbers)
        numbers = malloc (sizeof (FcChar16));
@@ -150,7 +152,9 @@ FcCharSetPutLeaf (FcCharSet *fcs,
        numbers = realloc (fcs->numbers, (fcs->num + 1) * sizeof (FcChar16));
     if (!numbers)
        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;
     
     memmove (fcs->leaves + pos + 1, fcs->leaves + pos, 
index 6c49591609a12eb7545d6b794f9cfbb42050e69d..3feb5ee88ffe173231941fa42a37670935b6eb2d 100644 (file)
@@ -129,7 +129,7 @@ FcFileScan (FcFontSet           *set,
                if (unparse)
                {
                    (void) FcGlobalCacheUpdate (cache, file, id, unparse);
-                   free (unparse);
+                   FcStrFree (unparse);
                }
            }
        }
@@ -181,6 +181,7 @@ FcDirScan (FcFontSet            *set,
            return FcTrue;
     }
     
+    /* freed below */
     file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + FC_MAX_FILE_LEN + 1);
     if (!file)
        return FcFalse;
index 8f16c74849bcc1deeb48e0faf3290134ac3d7d5a..b605918271a115e1331ac1ccc4dcfad7ffee6bb2 100644 (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.
  *
@@ -305,7 +305,7 @@ FcFreeTypeQuery (const FcChar8      *file,
                continue;
     
            /*
-            * Allocate plenty of space
+            * Allocate plenty of space.  Freed below
             */
            utf8 = malloc (len * FC_UTF8_MAX_LEN + 1);
            if (!utf8)
@@ -324,7 +324,7 @@ FcFreeTypeQuery (const FcChar8      *file,
            break;
        case FcNameEncodingLatin1:
            /*
-            * Convert Latin1 to Utf8
+            * Convert Latin1 to Utf8. Freed below
             */
            utf8 = malloc (src_len * 2 + 1);
            if (!utf8)
@@ -348,6 +348,7 @@ FcFreeTypeQuery (const FcChar8      *file,
            if (!map)
                continue;
 
+           /* freed below */
            utf8 = malloc (src_len * 3 + 1);
            if (!utf8)
                continue;
@@ -422,6 +423,7 @@ FcFreeTypeQuery (const FcChar8      *file,
        end = (FcChar8 *) strrchr ((char *) start, '.');
        if (!end)
            end = start + strlen ((char *) start);
+       /* freed below */
        family = malloc (end - start + 1);
        strncpy ((char *) family, (char *) start, end - start);
        family[end - start] = '\0';
index 778319428526271cf33c5537f85fab156235a75c..e28dc2ae30a36e74e63cf3c32a94a19dbd74e1f1 100644 (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.
  *
@@ -154,23 +154,35 @@ static struct {
     int            free_count;
     int            free_mem;
 } FcInUse[FC_MEM_NUM] = {
-    { "charset", 0, 0 },
-    { "charleaf", 0 ,0 },
-    { "fontset", 0, 0 },
-    { "fontptr", 0, 0 },
-    { "objectset", 0, 0 },
-    { "objectptr", 0, 0 },
-    { "matrix", 0, 0 },
-    { "pattern", 0, 0 },
-    { "patelt", 0, 0 },
-    { "vallist", 0, 0 },
-    { "substate", 0, 0 },
-    { "string", 0, 0 },
-    { "listbuck", 0, 0 },
-    { "strset", 0, 0 },
-    { "strlist", 0, 0 },
-    { "config", 0, 0 },
-    { "langset", 0, 0 },
+    { "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" },
 };
 
 static int  FcAllocCount, FcAllocMem;
index cd43b767fa77bcc7c9c1a7d20f2fc5277b9d4ddb..105a5511ac51b98ee432546a511ee220d6d6dd71 100644 (file)
@@ -81,8 +81,20 @@ typedef struct _FcSymbolic {
 #define FC_MEM_STRLIST     14
 #define FC_MEM_CONFIG      15
 #define FC_MEM_LANGSET     16
-
-#define FC_MEM_NUM         17
+#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         29
 
 typedef enum _FcValueBinding {
     FcValueBindingWeak, FcValueBindingStrong
index 20c0861a890d84eb80b35328c4efab62e10f6b24..8c76995cc3c8180c81991b41b16d514beadc025c 100644 (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.
  *
@@ -640,6 +640,7 @@ FcFontSetSort (FcConfig         *config,
     }
     if (!nnodes)
        goto bail0;
+    /* freed below */
     nodes = malloc (nnodes * sizeof (FcSortNode) + nnodes * sizeof (FcSortNode *));
     if (!nodes)
        goto bail0;
index e0ab9ffb14a15bf6fe13705ec93b23eedba9a6d7..4c0eb96d4b6cf12761c84ee727e2122f7c4a426a 100644 (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.
  *
@@ -88,6 +88,7 @@ FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes)
     l = (FcObjectTypeList *) malloc (sizeof (FcObjectTypeList));
     if (!l)
        return FcFalse;
+    FcMemAlloc (FC_MEM_OBJECTTYPE, sizeof (FcObjectTypeList));
     l->types = types;
     l->ntypes = ntypes;
     l->next = _FcObjectTypes;
@@ -107,6 +108,7 @@ FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes)
        if (l->types == types && l->ntypes == ntypes)
        {
            *prev = l->next;
+           FcMemFree (FC_MEM_OBJECTTYPE, sizeof (FcObjectTypeList));
            free ((void *) l);
            return FcTrue;
        }
@@ -181,6 +183,7 @@ 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;
@@ -200,6 +203,7 @@ 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;
        }
@@ -347,6 +351,7 @@ FcNameParse (const FcChar8 *name)
     const FcObjectType *t;
     const FcConstant   *c;
 
+    /* freed below */
     save = malloc (strlen ((char *) name) + 1);
     if (!save)
        goto bail0;
index 9c99170c6932d7a3f0880bc23d328806149e0945..4da57477373de29f3c3df72243fb8ccae4d0b0f7 100644 (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.
  *
@@ -482,6 +482,7 @@ FcPatternFreeze (FcPattern *p)
     b = (FcPattern *) malloc (size);
     if (!b)
        return 0;
+    FcMemAlloc (FC_MEM_PATTERN, size);
     b->num = p->num;
     b->size = b->num;
     b->ref = 1;
index fadc1de7ce33e845699aae96e264084474f19315..efb82e1358ad957586fe391bb9df89f76ca0d903 100644 (file)
@@ -341,6 +341,7 @@ FcStrBufDestroy (FcStrBuf *buf)
 {
     if (buf->allocated)
     {
+       FcMemFree (FC_MEM_STRBUF, buf->size);
        free (buf->buf);
        FcStrBufInit (buf, 0, 0);
     }
@@ -354,6 +355,7 @@ 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';
     }
@@ -389,6 +391,9 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c)
            buf->failed = FcTrue;
            return FcFalse;
        }
+       if (buf->size)
+           FcMemFree (FC_MEM_STRBUF, buf->size);
+       FcMemAlloc (FC_MEM_STRBUF, size);
        buf->size = size;
        buf->buf = new;
     }
index 5962b8dc753ba49e6b0a2db4256ba1bbe06ebb4a..f76d45fbc6d46bee107106c25580e13ecef19bc7 100644 (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.
  *
@@ -46,6 +46,7 @@ FcTestCreate (FcMatchKind   kind,
 
     if (test)
     {
+       FcMemAlloc (FC_MEM_TEST, sizeof (FcTest));
        test->next = 0;
        test->kind = kind;
        test->qual = qual;
@@ -63,6 +64,7 @@ FcTestDestroy (FcTest *test)
        FcTestDestroy (test->next);
     FcExprDestroy (test->expr);
     FcStrFree ((FcChar8 *) test->field);
+    FcMemFree (FC_MEM_TEST, sizeof (FcTest));
     free (test);
 }
 
@@ -73,6 +75,7 @@ FcExprCreateInteger (int i)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpInteger;
        e->u.ival = i;
     }
@@ -86,6 +89,7 @@ FcExprCreateDouble (double d)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpDouble;
        e->u.dval = d;
     }
@@ -99,6 +103,7 @@ FcExprCreateString (const FcChar8 *s)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpString;
        e->u.sval = FcStrCopy (s);
     }
@@ -112,6 +117,7 @@ FcExprCreateMatrix (const FcMatrix *m)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpMatrix;
        e->u.mval = FcMatrixCopy (m);
     }
@@ -125,6 +131,7 @@ FcExprCreateBool (FcBool b)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpBool;
        e->u.bval = b;
     }
@@ -138,6 +145,7 @@ FcExprCreateNil (void)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpNil;
     }
     return e;
@@ -150,6 +158,7 @@ FcExprCreateField (const char *field)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpField;
        e->u.field = (char *) FcStrCopy ((FcChar8 *) field);
     }
@@ -163,6 +172,7 @@ FcExprCreateConst (const FcChar8 *constant)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = FcOpConst;
        e->u.constant = FcStrCopy (constant);
     }
@@ -176,6 +186,7 @@ FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right)
 
     if (e)
     {
+       FcMemAlloc (FC_MEM_EXPR, sizeof (FcExpr));
        e->op = op;
        e->u.tree.left = left;
        e->u.tree.right = right;
@@ -240,6 +251,7 @@ FcExprDestroy (FcExpr *e)
     case FcOpInvalid:
        break;
     }
+    FcMemFree (FC_MEM_EXPR, sizeof (FcExpr));
     free (e);
 }
 
@@ -491,6 +503,7 @@ FcVStackCreate (void)
     new = malloc (sizeof (FcVStack));
     if (!new)
        return 0;
+    FcMemAlloc (FC_MEM_VSTACK, sizeof (FcVStack));
     new->tag = FcVStackNone;
     new->prev = 0;
     return new;
@@ -534,6 +547,7 @@ FcVStackDestroy (FcVStack *vstack)
            FcEditDestroy (vstack->u.edit);
            break;
        }
+       FcMemFree (FC_MEM_VSTACK, sizeof (FcVStack));
        free (vstack);
     }
 }
@@ -704,6 +718,7 @@ FcConfigSaveAttr (const XML_Char **attr)
     new = malloc ((i + 1) * sizeof (FcChar8 *) + slen);
     if (!new)
        return 0;
+    FcMemAlloc (FC_MEM_ATTR, 1);    /* size is too expensive */
     s = (FcChar8 *) (new + (i + 1));
     for (i = 0; attr[i]; i++)
     {
@@ -722,6 +737,7 @@ FcPStackPush (FcConfigParse *parse, FcElement element, const XML_Char **attr)
 
     if (!new)
        return FcFalse;
+    FcMemAlloc (FC_MEM_PSTACK, sizeof (FcPStack));
     new->prev = parse->pstack;
     new->element = element;
     if (attr)
@@ -752,7 +768,11 @@ FcPStackPop (FcConfigParse *parse)
     parse->pstack = old->prev;
     FcStrBufDestroy (&old->str);
     if (old->attr)
+    {
+       FcMemFree (FC_MEM_ATTR, 1); /* size is to expensive */
        free (old->attr);
+    }
+    FcMemFree (FC_MEM_PSTACK, sizeof (FcPStack));
     free (old);
     return FcTrue;
 }
@@ -1317,7 +1337,7 @@ FcParseInclude (FcConfigParse *parse)
        ignore_missing = FcTrue;
     if (!FcConfigParseAndLoad (parse->config, s, !ignore_missing))
        parse->error = FcTrue;
-    free (s);
+    FcStrFree (s);
 }
 
 typedef struct _FcOpMap {
@@ -1580,7 +1600,7 @@ FcEndElement(void *userData, const XML_Char *name)
        }
        if (!FcConfigAddDir (parse->config, data))
            FcConfigMessage (parse, FcSevereError, "out of memory");
-       free (data);
+       FcStrFree (data);
        break;
     case FcElementCache:
        data = FcStrBufDone (&parse->pstack->str);
@@ -1591,7 +1611,7 @@ FcEndElement(void *userData, const XML_Char *name)
        }
        if (!FcConfigSetCache (parse->config, data))
            FcConfigMessage (parse, FcSevereError, "out of memory");
-       free (data);
+       FcStrFree (data);
        break;
     case FcElementInclude:
        FcParseInclude (parse);
@@ -1759,10 +1779,13 @@ FcConfigParseAndLoad (FcConfig      *config,
        goto bail0;
     
     if (!FcStrSetAdd (config->configFiles, filename))
+    {
+       FcStrFree (filename);
        goto bail0;
+    }
 
     f = fopen ((char *) filename, "r");
-    free (filename);
+    FcStrFree (filename);
     if (!f)
        goto bail0;