Messages in this thread | | | Date | Fri, 20 Apr 2012 07:53:49 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH 02/13] perf annotate: Parse instruction |
| |
Em Thu, Apr 19, 2012 at 05:55:57PM -0600, David Ahern escreveu: > On 4/19/12 2:33 PM, Arnaldo Carvalho de Melo wrote: > > dl->offset = offset; > > dl->line = strdup(line); > > if (dl->line == NULL) > > goto out_delete; > >+ > >+ if (offset != -1) { > >+ char *name = dl->line, tmp; > >+ > >+ while (isspace(name[0])) > >+ ++name; > >+ > >+ if (name[0] == '\0') > >+ goto out_delete; > >+ > >+ dl->operands = name + 1; > >+ > >+ while (dl->operands[0] != '\0'&& > >+ !isspace(dl->operands[0])) > >+ ++dl->operands; > >+ > >+ tmp = dl->operands[0]; > >+ dl->operands[0] = '\0'; > >+ dl->name = strdup(name); > > This strdup seems unnecessary. The parsing seems to be: > > dl->line = "\W*name\W*operands" > dl->name = -^ ^- = dl_operands > > so name and operands are 2 different parts of the same buffer.
Yeah, but we still want to do searches in the whole line, sure we could do that using the name + operands parts, but I got lazy at that point.
- Arnaldo
| |