summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-11 13:48:39 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2009-05-11 13:48:39 (GMT)
commit7f34114f07a916e49b85d72fc9b1b0d3287f28d1 (patch)
treee99f2fd5501cebab16606fa5030db43478cbad98
parentacae6a226364604fe4692f118361af88c12977b0 (diff)
downloadttf2f-7f34114f07a916e49b85d72fc9b1b0d3287f28d1.tar.gz
ttf2f-7f34114f07a916e49b85d72fc9b1b0d3287f28d1.tar.bz2
Squash memory leaks
svn path=/trunk/tools/ttf2f/; revision=7468
-rw-r--r--src/cli.c4
-rw-r--r--src/fm.h4
-rw-r--r--src/ft.c22
3 files changed, 16 insertions, 14 deletions
diff --git a/src/cli.c b/src/cli.c
index 631077f..e38bb46 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -122,6 +122,10 @@ error_out:
}
}
+ free(ctx.metrics->name_copyright);
+ free(ctx.metrics->name_full);
+ free(ctx.metrics->name_version);
+ free(ctx.metrics->name_ps);
free(ctx.metrics);
free(ctx.glyphs);
diff --git a/src/fm.h b/src/fm.h
index f8e024e..3e87cf6 100644
--- a/src/fm.h
+++ b/src/fm.h
@@ -18,8 +18,8 @@ struct font_metrics {
/* name */
char *name_copyright;
- char *name_family;
- char *name_style;
+ const char *name_family;
+ const char *name_style;
char *name_full;
char *name_version;
char *name_ps;
diff --git a/src/ft.c b/src/ft.c
index 0fe7c51..67a4c9e 100644
--- a/src/ft.c
+++ b/src/ft.c
@@ -234,8 +234,8 @@ int fnmetrics(ttf2f_ctx *ctx)
{
FT_Face f = (FT_Face) ctx->face;
struct font_metrics *fm = ctx->metrics;
- char *str;
- static char *fieldstocheck[3];
+ const char *str;
+ const char *fieldstocheck[3];
FT_SfntName sn;
TT_Postscript *post;
int i, j, len;
@@ -265,7 +265,7 @@ int fnmetrics(ttf2f_ctx *ctx)
}
if (FT_Get_Sfnt_Name(f, TT_NAME_ID_COPYRIGHT, &sn)) {
- fm->name_copyright = (char *) "";
+ fm->name_copyright = strdup("");
} else {
fm->name_copyright = strndup((const char*)sn.string,
sn.string_len);
@@ -295,7 +295,7 @@ int fnmetrics(ttf2f_ctx *ctx)
fm->name_full = strndup((const char*)sn.string, sn.string_len);
if (FT_Get_Sfnt_Name(f, TT_NAME_ID_VERSION_STRING, &sn)) {
- fm->name_version = (char *) "1.0";
+ fm->name_version = strdup("1.0");
} else {
fm->name_version = strndup((const char*)sn.string,
sn.string_len);
@@ -323,18 +323,16 @@ int fnmetrics(ttf2f_ctx *ctx)
fieldstocheck[1] = fm->name_full;
fieldstocheck[2] = fm->name_ps;
- for (i = 0; !fm->force_bold &&
- i < (int) (sizeof fieldstocheck / sizeof(fieldstocheck[0]));
+ for (i = 0; !fm->force_bold && i < (int) N_ELEMENTS(fieldstocheck);
i++) {
- str=fieldstocheck[i];
+ str = fieldstocheck[i];
len = strlen(str);
for (j = 0; j < len; j++) {
- if ((str[j]=='B'
- || str[j]=='b')
- && (j==0 || !isalpha(str[j-1]))
- && !strncmp("old",&str[j+1],3)
- && (j+4 >= len || !islower(str[j+4]))) {
+ if ((str[j] == 'B' || str[j] == 'b') &&
+ (j == 0 || !isalpha(str[j-1])) &&
+ !strncmp("old", &str[j+1], 3) &&
+ (j + 4 >= len || !islower(str[j+4]))) {
fm->force_bold=1;
break;
}