summaryrefslogtreecommitdiff
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
parent4af0cf6ef7309df18c81a1fd109a168c767d9f3d (diff)
downloadxorg-lib-libfontenc-2218195ebb18b620f9e8e0adbea6f7c87ace33ce.tar.gz
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>
-rw-r--r--src/encparse.c12
-rw-r--r--src/fontenc.c3
2 files changed, 5 insertions, 10 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;
}
diff --git a/src/fontenc.c b/src/fontenc.c
index 1a24fc2..8718eff 100644
--- a/src/fontenc.c
+++ b/src/fontenc.c
@@ -753,10 +753,9 @@ FontEncLoad(const char *encoding_name, const char *filename)
char *new_name;
int numaliases = 0;
- new_name = malloc(strlen(encoding_name) + 1);
+ new_name = strdup(encoding_name);
if(new_name == NULL)
return NULL;
- strcpy(new_name, encoding_name);
if(encoding->aliases) {
for(alias = encoding->aliases; *alias; alias++)
numaliases++;