aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-alpha.c
diff options
context:
space:
mode:
Diffstat (limited to 'gas/config/tc-alpha.c')
-rw-r--r--gas/config/tc-alpha.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c
index 89eaf88..638f160 100644
--- a/gas/config/tc-alpha.c
+++ b/gas/config/tc-alpha.c
@@ -1417,9 +1417,7 @@ load_expression (int targreg,
ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2)
ptr1 = symname;
- psymname = (char *) xmalloc (ptr2 - ptr1 + 1);
- memcpy (psymname, ptr1, ptr2 - ptr1);
- psymname [ptr2 - ptr1] = 0;
+ psymname = xmemdup0 (ptr1, ptr2 - ptr1);
gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_LDA;
@@ -3959,9 +3957,7 @@ s_alpha_file (int ignore ATTRIBUTE_UNUSED)
discard_rest_of_line ();
len = input_line_pointer - start;
- first_file_directive = (char *) xmalloc (len + 1);
- memcpy (first_file_directive, start, len);
- first_file_directive[len] = '\0';
+ first_file_directive = xmemdup0 (start, len);
input_line_pointer = start;
}
@@ -4214,9 +4210,7 @@ s_alpha_section_name (void)
return NULL;
}
- name = xmalloc (end - input_line_pointer + 1);
- memcpy (name, input_line_pointer, end - input_line_pointer);
- name[end - input_line_pointer] = '\0';
+ name = xmemdup0 (input_line_pointer, end - input_line_pointer);
input_line_pointer = end;
}
SKIP_WHITESPACE ();
@@ -6283,10 +6277,7 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED,
if (pname_len > 4 && strcmp (pname + pname_len - 4, "..en") == 0)
{
symbolS *sym;
- char *my_pname = (char *) xmalloc (pname_len - 4 + 1);
-
- memcpy (my_pname, pname, pname_len - 4);
- my_pname [pname_len - 4] = 0;
+ char *my_pname = xmemdup0 (pname, pname_len - 4);
sym = symbol_find (my_pname);
free (my_pname);
if (sym == NULL)