summaryrefslogtreecommitdiff
path: root/src/encparse.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-05-14 20:09:21 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-05-17 08:20:23 -0700
commit2218195ebb18b620f9e8e0adbea6f7c87ace33ce (patch)
treea85f18fc3ffba00de28195243a8a8716e86603d8 /src/encparse.c
parent4af0cf6ef7309df18c81a1fd109a168c767d9f3d (diff)
Replace malloc(strlen()) + strcpy() with strdup()
Now that we use malloc directly instead of xalloc, we can use strdup directly too. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jamey Sharp <jamey@minilop.net>
Diffstat (limited to 'src/encparse.c')
-rw-r--r--src/encparse.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/encparse.c b/src/encparse.c
index b288c8c..33e0a05 100644
--- a/src/encparse.c
+++ b/src/encparse.c
@@ -488,10 +488,9 @@ parseEncodingFile(FontFilePtr f, int headerOnly)
encoding = malloc(sizeof(FontEncRec));
if(encoding == NULL)
goto error;
- encoding->name = malloc(strlen(keyword_value)+1);
+ encoding->name = strdup(keyword_value);
if(encoding->name == NULL)
goto error;
- strcpy(encoding->name, keyword_value);
encoding->size = 256;
encoding->row_size = 0;
encoding->mappings = NULL;
@@ -508,10 +507,9 @@ parseEncodingFile(FontFilePtr f, int headerOnly)
case EOF_LINE: goto done;
case ALIAS_LINE:
if(numaliases < MAXALIASES) {
- aliases[numaliases] = malloc(strlen(keyword_value)+1);
+ aliases[numaliases] = strdup(keyword_value);
if(aliases[numaliases] == NULL)
goto error;
- strcpy(aliases[numaliases], keyword_value);
numaliases++;
}
goto no_mapping;
@@ -718,11 +716,10 @@ parseEncodingFile(FontFilePtr f, int headerOnly)
nam[i]=NULL;
last = value1;
}
- nam[value1] = malloc(strlen(keyword_value)+1);
+ nam[value1] = strdup(keyword_value);
if(nam[value1] == NULL) {
goto error;
}
- strcpy(nam[value1], keyword_value);
goto string_mapping;
default: goto string_mapping; /* ignore unknown lines */
@@ -781,10 +778,9 @@ FontEncDirectory(void)
if(dir == NULL) {
char *c = getenv("FONT_ENCODINGS_DIRECTORY");
if(c) {
- dir = malloc(strlen(c) + 1);
+ dir = strdup(c);
if(!dir)
return NULL;
- strcpy(dir, c);
} else {
dir = FONT_ENCODINGS_DIRECTORY;
}