fc-cat/fc-cat.c | 2 +- fc-list/fc-list.c | 2 +- fc-match/fc-match.c | 2 +- fc-pattern/fc-pattern.c | 2 +- fc-query/fc-query.c | 2 +- fc-scan/fc-scan.c | 2 +- src/fccfg.c | 12 ++++++++---- src/fcformat.c | 4 ++-- src/fcpat.c | 3 ++- src/fcstr.c | 3 +-- src/fcxml.c | 11 +++++++++-- 11 files changed, 28 insertions(+), 17 deletions(-) New commits: commit 1b692d8ab91a096e7d433c51ab187382de91147b Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Jun 1 19:06:17 2012 +0900 Fix the wrong estimation for the memory usage information in fontconfig diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c index b273f25..72912b7 100644 --- a/fc-cat/fc-cat.c +++ b/fc-cat/fc-cat.c @@ -231,7 +231,7 @@ cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBoo if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } if (verbose && !set->nfont && !ndir) diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c index 0149b0c..eb7b688 100644 --- a/fc-list/fc-list.c +++ b/fc-list/fc-list.c @@ -183,7 +183,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } } diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c index 4642c8d..8ae8ee9 100644 --- a/fc-match/fc-match.c +++ b/fc-match/fc-match.c @@ -230,7 +230,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } diff --git a/fc-pattern/fc-pattern.c b/fc-pattern/fc-pattern.c index aa51e5f..84eb1ee 100644 --- a/fc-pattern/fc-pattern.c +++ b/fc-pattern/fc-pattern.c @@ -176,7 +176,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } else diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c index 0680b92..2ed18a2 100644 --- a/fc-query/fc-query.c +++ b/fc-query/fc-query.c @@ -165,7 +165,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } else diff --git a/fc-scan/fc-scan.c b/fc-scan/fc-scan.c index ebf5606..c852e0d 100644 --- a/fc-scan/fc-scan.c +++ b/fc-scan/fc-scan.c @@ -168,7 +168,7 @@ main (int argc, char **argv) if (s) { printf ("%s", s); - free (s); + FcStrFree (s); } } else diff --git a/src/fccfg.c b/src/fccfg.c index 5b72492..b45d74a 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -1698,17 +1698,17 @@ static FcChar8 * FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) { FcChar8 *path; - int size; + int size, osize; if (!dir) dir = (FcChar8 *) ""; - size = strlen ((char *) dir) + 1 + strlen ((char *) file) + 1; + osize = strlen ((char *) dir) + 1 + strlen ((char *) file) + 1; /* * workaround valgrind warning because glibc takes advantage of how it knows memory is * allocated to implement strlen by reading in groups of 4 */ - size = (size + 3) & ~3; + size = (osize + 3) & ~3; path = malloc (size); if (!path) @@ -1729,11 +1729,12 @@ FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file) #endif strcat ((char *) path, (char *) file); - FcMemAlloc (FC_MEM_STRING, size); + FcMemAlloc (FC_MEM_STRING, osize); if (access ((char *) path, R_OK) == 0) return path; FcStrFree (path); + return 0; } @@ -1853,6 +1854,7 @@ 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; @@ -1878,6 +1880,7 @@ 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; @@ -1903,6 +1906,7 @@ 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/fcformat.c b/src/fcformat.c index 0e63d5d..8eef7bb 100644 --- a/src/fcformat.c +++ b/src/fcformat.c @@ -294,7 +294,7 @@ interpret_builtin (FcFormatContext *c, if (new_str) { FcStrBufString (buf, new_str); - free (new_str); + FcStrFree (new_str); return FcTrue; } else @@ -1014,7 +1014,7 @@ interpret_convert (FcFormatContext *c, if (new_str) { FcStrBufString (buf, new_str); - free (new_str); + FcStrFree (new_str); return FcTrue; } else diff --git a/src/fcpat.c b/src/fcpat.c index 54ec45c..ebd6e57 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -1046,7 +1046,8 @@ FcSharedStrFree (const FcChar8 *name) { *p = b->next; size = sizeof (struct objectBucket) + strlen ((char *)name) + 1; - FcMemFree (FC_MEM_SHAREDSTR, size + sizeof (int)); + size = (size + 3) & ~3; + FcMemFree (FC_MEM_SHAREDSTR, size); free (b); } return FcTrue; diff --git a/src/fcstr.c b/src/fcstr.c index f20d05e..e372af0 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -833,6 +833,7 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c) if (buf->allocated) { size = buf->size * 2; + FcMemFree (FC_MEM_STRBUF, buf->size); new = realloc (buf->buf, size); } else @@ -850,8 +851,6 @@ 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; diff --git a/src/fcxml.c b/src/fcxml.c index d92cbcc..5201b3c 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -1359,6 +1359,7 @@ FcParseRange (FcConfigParse *parse) break; default: FcConfigMessage (parse, FcSevereError, "invalid element in range"); + n = 0; break; } if (count == 1) @@ -1864,12 +1865,14 @@ FcParseDir (FcConfigParse *parse) size_t plen = strlen ((const char *)prefix); size_t dlen = strlen ((const char *)data); + FcMemFree (FC_MEM_STRING, plen + 1); prefix = realloc (prefix, plen + 1 + dlen + 1); if (!prefix) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], data, dlen); prefix[plen + 1 + dlen] = 0; @@ -1934,7 +1937,7 @@ FcParseDir (FcConfigParse *parse) bail: if (prefix) - free (prefix); + FcStrFree (prefix); } static void @@ -1957,12 +1960,14 @@ FcParseCacheDir (FcConfigParse *parse) size_t plen = strlen ((const char *)prefix); size_t dlen = strlen ((const char *)data); + FcMemFree (FC_MEM_STRING, plen + 1); prefix = realloc (prefix, plen + 1 + dlen + 1); if (!prefix) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], data, dlen); prefix[plen + 1 + dlen] = 0; @@ -2053,12 +2058,14 @@ FcParseInclude (FcConfigParse *parse) size_t plen = strlen ((const char *)prefix); size_t dlen = strlen ((const char *)s); + FcMemFree (FC_MEM_STRING, plen + 1); prefix = realloc (prefix, plen + 1 + dlen + 1); if (!prefix) { FcConfigMessage (parse, FcSevereError, "out of memory"); goto bail; } + FcMemAlloc (FC_MEM_STRING, plen + 1 + dlen + 1); prefix[plen] = FC_DIR_SEPARATOR; memcpy (&prefix[plen + 1], s, dlen); prefix[plen + 1 + dlen] = 0; @@ -2076,7 +2083,7 @@ FcParseInclude (FcConfigParse *parse) bail: if (prefix) - free (prefix); + FcStrFree (prefix); } typedef struct _FcOpMap { _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig