This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] constify search_symbols
- From: Yao Qi <yao at codesourcery dot com>
- To: Tom Tromey <tromey at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Tue, 24 Jun 2014 11:09:57 +0800
- Subject: Re: [PATCH] constify search_symbols
- Authentication-results: sourceware.org; auth=none
- References: <1403285060-5556-1-git-send-email-tromey at redhat dot com>
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 (éå)