diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-01-18 10:43:11 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-01-25 19:51:36 -0800 |
commit | 47fa41960650dd0e97eb78de2af0f5fcd9323b35 (patch) | |
tree | bbfbc9889d3346a54b3ceabf4bc8fe763a372851 /util | |
parent | f3e5903536f80cb42ee6841f85e013284eb4c2fc (diff) |
makestrs: Replace malloc()+strcpy() calls with strdup() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/makestrs.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/util/makestrs.c b/util/makestrs.c index 2c4dcc8..7853f87 100644 --- a/util/makestrs.c +++ b/util/makestrs.c @@ -498,9 +498,8 @@ static void DoLine(char *buf) if ((phile = (File*) malloc (sizeof(File))) == NULL) exit(1); - if ((phile->name = malloc (strlen (buf + strlen (file_str)) + 1)) == NULL) + if ((phile->name = strdup (buf + strlen (file_str) + 1)) == NULL) exit(1); - (void) strcpy (phile->name, buf + strlen (file_str) + 1); phile->table = NULL; phile->tablecurrent = NULL; phile->tabletail = &phile->table; @@ -517,9 +516,8 @@ static void DoLine(char *buf) Table* table; if ((table = (Table*) malloc (sizeof(Table))) == NULL) exit(1); - if ((table->name = malloc (strlen (buf + strlen (table_str)) + 1)) == NULL) + if ((table->name = strdup (buf + strlen (table_str) + 1)) == NULL) exit(1); - (void) strcpy (table->name, buf + strlen (table_str) + 1); if (solaris_abi_names) { if (strcmp(table->name, "XtStringsR6") == 0) { strcpy(table->name, "XtR6Strings"); @@ -539,29 +537,24 @@ static void DoLine(char *buf) } break; case X_PREFIX_TOKEN: - if ((prefixstr = malloc (strlen (buf + strlen (prefix_str)) + 1)) == NULL) + if ((prefixstr = strdup (buf + strlen (prefix_str) + 1)) == NULL) exit(1); - (void) strcpy (prefixstr, buf + strlen (prefix_str) + 1); break; case X_FEATURE_TOKEN: - if ((featurestr = malloc (strlen (buf + strlen (feature_str)) + 1)) == NULL) + if ((featurestr = strdup (buf + strlen (feature_str) + 1)) == NULL) exit(1); - (void) strcpy (featurestr, buf + strlen (feature_str) + 1); break; case X_EXTERNREF_TOKEN: - if ((externrefstr = malloc (strlen (buf + strlen (externref_str)) + 1)) == NULL) + if ((externrefstr = strdup (buf + strlen (externref_str) + 1)) == NULL) exit(1); - (void) strcpy (externrefstr, buf + strlen (externref_str) + 1); break; case X_EXTERNDEF_TOKEN: - if ((externdefstr = malloc (strlen (buf + strlen (externdef_str)) + 1)) == NULL) + if ((externdefstr = strdup (buf + strlen (externdef_str) + 1)) == NULL) exit(1); - (void) strcpy (externdefstr, buf + strlen (externdef_str) + 1); break; case X_CTMPL_TOKEN: - if ((ctmplstr = malloc (strlen (buf + strlen (ctmpl_str)) + 1)) == NULL) + if ((ctmplstr = strdup (buf + strlen (ctmpl_str) + 1)) == NULL) exit(1); - (void) strcpy (ctmplstr, buf + strlen (ctmpl_str) + 1); break; case X_HTMPL_TOKEN: if ((filecurrent->tmpl = ifopen (buf + strlen (htmpl_str) + 1, "r")) == NULL) { @@ -571,9 +564,8 @@ static void DoLine(char *buf) } break; case X_CONST_TOKEN: - if ((conststr = malloc (strlen (buf + strlen (const_str)) + 1)) == NULL) + if ((conststr = strdup (buf + strlen (const_str) + 1)) == NULL) exit(1); - (void) strcpy (conststr, buf + strlen (const_str) + 1); break; default: { |