This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Constify find_condition_and_thread
- From: Pedro Alves <palves at redhat dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Fri, 01 Mar 2013 18:56:09 +0000
- Subject: Re: [RFA] Constify find_condition_and_thread
- References: <5130F0FD.2040203@redhat.com>
On 03/01/2013 06:18 PM, Keith Seitz wrote:
> else if (toklen >= 1 && strncmp (tok, "task", toklen) == 0)
> {
> - char *tmptok;
> + char *tmptok, *copy;
>
> tok = end_tok + 1;
> - tmptok = tok;
> - *task = strtol (tok, &tok, 0);
> - if (tok == tmptok)
> - error (_("Junk after task keyword."));
> + tmptok = copy = xstrdup (tok);
> + *task = strtol (copy, ©, 0);
> + if (copy == tmptok)
> + {
> + xfree (tmptok);
> + error (_("Junk after task keyword."));
> + }
Why do we really need the xstrdups in this and the "task" cases?
> +const char *
> +skip_to_space_const (const char *chp)
> +{
> + if (chp == NULL)
> + return NULL;
> + while (*chp && !isspace (*chp))
> + chp++;
> + return chp;
> +}
Note we in addition redo skip_to_space as:
char *
skip_to_space (char *chp)
{
return (char *) skip_to_space_const (chp);
}
(or make that an inline function / #define)
--
Pedro Alves