Fix the wrong estimation for the memory usage information in fontconfig
This commit is contained in:
parent
5254a6630f
commit
1b692d8ab9
|
@ -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)
|
||||
|
|
|
@ -183,7 +183,7 @@ main (int argc, char **argv)
|
|||
if (s)
|
||||
{
|
||||
printf ("%s", s);
|
||||
free (s);
|
||||
FcStrFree (s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ main (int argc, char **argv)
|
|||
if (s)
|
||||
{
|
||||
printf ("%s", s);
|
||||
free (s);
|
||||
FcStrFree (s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ main (int argc, char **argv)
|
|||
if (s)
|
||||
{
|
||||
printf ("%s", s);
|
||||
free (s);
|
||||
FcStrFree (s);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -165,7 +165,7 @@ main (int argc, char **argv)
|
|||
if (s)
|
||||
{
|
||||
printf ("%s", s);
|
||||
free (s);
|
||||
FcStrFree (s);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -168,7 +168,7 @@ main (int argc, char **argv)
|
|||
if (s)
|
||||
{
|
||||
printf ("%s", s);
|
||||
free (s);
|
||||
FcStrFree (s);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
12
src/fccfg.c
12
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
11
src/fcxml.c
11
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 {
|
||||
|
|
Loading…
Reference in New Issue