Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349985
b: refs/heads/master
c: ffe0fb7
h: refs/heads/master
i:
  349983: d027d1e
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 24, 2013
1 parent 65da552 commit 2ee358f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5a3d04d6dc9050b4b4562f5c66aea23f0aa1c003
refs/heads/master: ffe0fb769a6db3b6027d9228b6fecb6b352e4834
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
static struct intlist *seen;

if (!seen)
seen = intlist__new();
seen = intlist__new(NULL);

if (!intlist__has_entry(seen, event->ip.pid)) {
pr_err("Can't find guest [%d]'s kernel information\n",
Expand Down
27 changes: 26 additions & 1 deletion trunk/tools/perf/util/intlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,26 @@ struct int_node *intlist__find(struct intlist *ilist, int i)
return node;
}

struct intlist *intlist__new(void)
static int intlist__parse_list(struct intlist *ilist, const char *s)
{
char *sep;
int err;

do {
long value = strtol(s, &sep, 10);
err = -EINVAL;
if (*sep != ',' && *sep != '\0')
break;
err = intlist__add(ilist, value);
if (err)
break;
s = sep + 1;
} while (*sep != '\0');

return err;
}

struct intlist *intlist__new(const char *slist)
{
struct intlist *ilist = malloc(sizeof(*ilist));

Expand All @@ -82,9 +101,15 @@ struct intlist *intlist__new(void)
ilist->rblist.node_cmp = intlist__node_cmp;
ilist->rblist.node_new = intlist__node_new;
ilist->rblist.node_delete = intlist__node_delete;

if (slist && intlist__parse_list(ilist, slist))
goto out_delete;
}

return ilist;
out_delete:
intlist__delete(ilist);
return NULL;
}

void intlist__delete(struct intlist *ilist)
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/util/intlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct intlist {
struct rblist rblist;
};

struct intlist *intlist__new(void);
struct intlist *intlist__new(const char *slist);
void intlist__delete(struct intlist *ilist);

void intlist__remove(struct intlist *ilist, struct int_node *in);
Expand Down

0 comments on commit 2ee358f

Please sign in to comment.