This increases consistancy of how we allocate memory, and always casting the
result to the proper type. It also helps make sure we get any use of sizeof on
the result type correct.
gas/ChangeLog:
2016-03-22 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* listing.c (listing_message): Use XNEW style allocation macros.
* read.c (read_a_source_file): Likewise.
(read_symbol_name): Likewise.
(s_mri_common): Likewise.
(assign_symbol): Likewise.
(s_reloc): Likewise.
(emit_expr_with_reloc): Likewise.
(s_incbin): Likewise.
(s_include): Likewise.
* sb.c (sb_build): Likewise.
(sb_check): Likewise.
+2016-03-22 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
+
+ * listing.c (listing_message): Use XNEW style allocation macros.
+ * read.c (read_a_source_file): Likewise.
+ (read_symbol_name): Likewise.
+ (s_mri_common): Likewise.
+ (assign_symbol): Likewise.
+ (s_reloc): Likewise.
+ (emit_expr_with_reloc): Likewise.
+ (s_incbin): Likewise.
+ (s_include): Likewise.
+ * sb.c (sb_build): Likewise.
+ (sb_check): Likewise.
+
2016-03-22 Alan Modra <amodra@gmail.com>
* write.c (record_alignment): Revert 2016-02-18 change.
2016-03-22 Alan Modra <amodra@gmail.com>
* write.c (record_alignment): Revert 2016-02-18 change.
{
unsigned int l = strlen (name) + strlen (message) + 1;
char *n = (char *) xmalloc (l);
{
unsigned int l = strlen (name) + strlen (message) + 1;
char *n = (char *) xmalloc (l);
- struct list_message *lm = xmalloc (sizeof *lm);
+ struct list_message *lm = XNEW (struct list_message);
strcpy (n, name);
strcat (n, message);
lm->message = n;
strcpy (n, name);
strcat (n, message);
lm->message = n;
/* Copy it for safe keeping. Also give an indication of
how much macro nesting is involved at this point. */
len = s - input_line_pointer;
/* Copy it for safe keeping. Also give an indication of
how much macro nesting is involved at this point. */
len = s - input_line_pointer;
- copy = (char *) xmalloc (len + macro_nest + 2);
+ copy = XNEWVEC (char, len + macro_nest + 2);
memset (copy, '>', macro_nest);
copy[macro_nest] = ' ';
memcpy (copy + macro_nest + 1, input_line_pointer, len);
memset (copy, '>', macro_nest);
copy[macro_nest] = ' ';
memcpy (copy + macro_nest + 1, input_line_pointer, len);
that goes with this #APP There is one. The specs
guarantee it... */
tmp_len = buffer_limit - s;
that goes with this #APP There is one. The specs
guarantee it... */
tmp_len = buffer_limit - s;
- tmp_buf = (char *) xmalloc (tmp_len + 1);
+ tmp_buf = XNEWVEC (char, tmp_len + 1);
memcpy (tmp_buf, s, tmp_len);
do
{
memcpy (tmp_buf, s, tmp_len);
do
{
else
num = buffer_limit - buffer;
else
num = buffer_limit - buffer;
- tmp_buf = (char *) xrealloc (tmp_buf, tmp_len + num);
+ tmp_buf = XRESIZEVEC (char, tmp_buf, tmp_len + num);
memcpy (tmp_buf + tmp_len, buffer, num);
tmp_len += num;
}
memcpy (tmp_buf + tmp_len, buffer, num);
tmp_len += num;
}
scrub_string_end = ends;
new_length = ends - s;
scrub_string_end = ends;
new_length = ends - s;
- new_buf = (char *) xmalloc (new_length);
+ new_buf = XNEWVEC (char, new_length);
new_tmp = new_buf;
for (;;)
{
new_tmp = new_buf;
for (;;)
{
- new_buf = (char *) xrealloc (new_buf, new_length + 100);
+ new_buf = XRESIZEVEC (char, new_buf, new_length + 100);
new_tmp = new_buf + new_length;
new_length += 100;
}
new_tmp = new_buf + new_length;
new_length += 100;
}
char * name_end;
unsigned int C;
char * name_end;
unsigned int C;
- start = name = xmalloc (len + 1);
+ start = name = XNEWVEC (char, len + 1);
name_end = name + SYM_NAME_CHUNK_LEN;
name_end = name + SYM_NAME_CHUNK_LEN;
sofar = name - start;
len += SYM_NAME_CHUNK_LEN;
sofar = name - start;
len += SYM_NAME_CHUNK_LEN;
- start = xrealloc (start, len + 1);
+ start = XRESIZEVEC (char, start, len + 1);
name_end = start + len;
name = start + sofar;
}
name_end = start + len;
name = start + sofar;
}
;
len = (input_line_pointer - name) - 1;
;
len = (input_line_pointer - name) - 1;
- start = xmalloc (len + 1);
+ start = XNEWVEC (char, len + 1);
memcpy (start, name, len);
start[len] = 0;
memcpy (start, name, len);
start[len] = 0;
if (line_label != NULL)
{
if (line_label != NULL)
{
- alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
- + (input_line_pointer - name)
- + 1);
+ alc = XNEWVEC (char, strlen (S_GET_NAME (line_label))
+ + (input_line_pointer - name) + 1);
sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
name = alc;
}
sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
name = alc;
}
if (listing & LISTING_SYMBOLS)
{
extern struct list_info_struct *listing_tail;
if (listing & LISTING_SYMBOLS)
{
extern struct list_info_struct *listing_tail;
- fragS *dummy_frag = (fragS *) xcalloc (1, sizeof (fragS));
+ fragS *dummy_frag = XCNEW (fragS);
dummy_frag->line = listing_tail;
dummy_frag->fr_symbol = symbolP;
symbol_set_frag (symbolP, dummy_frag);
dummy_frag->line = listing_tail;
dummy_frag->fr_symbol = symbolP;
symbol_set_frag (symbolP, dummy_frag);
{ "64", BFD_RELOC_64 }
};
{ "64", BFD_RELOC_64 }
};
- reloc = (struct reloc_list *) xmalloc (sizeof (*reloc));
+ reloc = XNEW (struct reloc_list);
if (flag_mri)
stop = mri_comment_field (&stopc);
if (flag_mri)
stop = mri_comment_field (&stopc);
- x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
+ x = XNEW (struct broken_word);
x->next_broken_word = broken_words;
broken_words = x;
x->seg = now_seg;
x->next_broken_word = broken_words;
broken_words = x;
x->seg = now_seg;
- path = (char *) xmalloc ((unsigned long) len + include_dir_maxlen + 5);
+ path = XNEWVEC (char, (unsigned long) len + include_dir_maxlen + 5);
for (i = 0; i < include_dir_count; i++)
{
for (i = 0; i < include_dir_count; i++)
{
}
demand_empty_rest_of_line ();
}
demand_empty_rest_of_line ();
- path = (char *) xmalloc ((unsigned long) i
- + include_dir_maxlen + 5 /* slop */ );
+ path = XNEWVEC (char, (unsigned long) i
+ + include_dir_maxlen + 5 /* slop */ );
for (i = 0; i < include_dir_count; i++)
{
for (i = 0; i < include_dir_count; i++)
{
void
sb_build (sb *ptr, size_t size)
{
void
sb_build (sb *ptr, size_t size)
{
- ptr->ptr = xmalloc (size + 1);
+ ptr->ptr = XNEWVEC (char, size + 1);
ptr->max = size;
ptr->len = 0;
}
ptr->max = size;
ptr->len = 0;
}
#endif
max -= MALLOC_OVERHEAD + 1;
ptr->max = max;
#endif
max -= MALLOC_OVERHEAD + 1;
ptr->max = max;
- ptr->ptr = xrealloc (ptr->ptr, max + 1);
+ ptr->ptr = XRESIZEVEC (char, ptr->ptr, max + 1);