This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] constify search_symbols


On 06/21/2014 01:24 AM, Tom Tromey wrote:
> -  char **files = NULL, *file_name;
> +  const char **files = NULL;
> +  const char *file_name;
>    int nfiles = 0;
>  
>    if (regexp)
> @@ -3960,13 +3961,15 @@ rbreak_command (char *regexp, int from_tty)
>        if (colon && *(colon + 1) != ':')
>  	{
>  	  int colon_index;
> +	  char *local_name;
>  
>  	  colon_index = colon - regexp;
> -	  file_name = alloca (colon_index + 1);
> -	  memcpy (file_name, regexp, colon_index);
> -	  file_name[colon_index--] = 0;
> -	  while (isspace (file_name[colon_index]))
> -	    file_name[colon_index--] = 0; 
> +	  local_name = alloca (colon_index + 1);
> +	  memcpy (local_name, regexp, colon_index);
> +	  local_name[colon_index--] = 0;
> +	  while (isspace (local_name[colon_index]))
> +	    local_name[colon_index--] = 0;
> +	  file_name = local_name;

file_name isn't used out side of this block, so we can define file_name
within this block of type "char *", and patch can be shorter.

-- 
Yao (éå)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]