From: Alan Modra Date: Mon, 3 Aug 2020 01:29:38 +0000 (+0930) Subject: Use xmalloc rather than malloc X-Git-Tag: binutils-2_35_1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06e5c19999f9f63b31fa4965686b8b536cb28561;p=thirdparty%2Fbinutils-gdb.git Use xmalloc rather than malloc As far as I can tell, the following comment is false nowadays. /* Calls to m-alloc get turned by sed into xm-alloc. */ Remove it, and call xmalloc. * ldlex.l (yy_create_string_buffer): Use xmalloc rather than malloc. * lexsup.c (parse_args): Likewise. (cherry picked from commit ee44c2ac7b3efdfd28c41cd32d7fb935b0582a97) --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 54e959cce4b..ad6a252dd74 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2020-08-03 Alan Modra + + * ldlex.l (yy_create_string_buffer): Use xmalloc rather than malloc. + * lexsup.c (parse_args): Likewise. + 2020-08-03 Alan Modra PR 26328 diff --git a/ld/ldlex.l b/ld/ldlex.l index 0fcbe84c8b5..4bd523eda65 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -515,14 +515,13 @@ yy_create_string_buffer (const char *string, size_t size) { YY_BUFFER_STATE b; - /* Calls to m-alloc get turned by sed into xm-alloc. */ - b = malloc (sizeof (struct yy_buffer_state)); + b = xmalloc (sizeof (struct yy_buffer_state)); b->yy_input_file = 0; b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = malloc ((unsigned) (b->yy_buf_size + 3)); + b->yy_ch_buf = xmalloc ((size_t) b->yy_buf_size + 3); b->yy_ch_buf[0] = '\n'; strcpy (b->yy_ch_buf+1, string); diff --git a/ld/lexsup.c b/ld/lexsup.c index 58c6c078325..6cab41cf5df 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -605,7 +605,7 @@ parse_args (unsigned argc, char **argv) longopts = (struct option *) xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1)); really_longopts = (struct option *) - malloc (sizeof (*really_longopts) * (OPTION_COUNT + 1)); + xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1)); /* Starting the short option string with '-' is for programs that expect options and other ARGV-elements in any order and that care about