Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304936
b: refs/heads/master
c: c46219a
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed May 12, 2012
1 parent a4a40c5 commit cc1a381
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 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: 7a997fe4019f556a81530d3a737d817a2b0d622f
refs/heads/master: c46219ac34f0f365bac700ca6a10ef979c643233
28 changes: 20 additions & 8 deletions trunk/tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ const char *disassembler_style;
static struct ins *ins__find(const char *name);
static int disasm_line__parse(char *line, char **namep, char **rawp);

static void ins__delete(struct ins_operands *ops)
{
free(ops->source.raw);
free(ops->source.name);
free(ops->target.raw);
free(ops->target.name);
}

static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops)
{
Expand Down Expand Up @@ -192,7 +200,15 @@ static int lock__scnprintf(struct ins *ins, char *bf, size_t size,
size - printed, ops->locked.ops);
}

static void lock__delete(struct ins_operands *ops)
{
free(ops->locked.ops);
free(ops->target.raw);
free(ops->target.name);
}

static struct ins_ops lock_ops = {
.free = lock__delete,
.parse = lock__parse,
.scnprintf = lock__scnprintf,
};
Expand Down Expand Up @@ -542,14 +558,10 @@ void disasm_line__free(struct disasm_line *dl)
{
free(dl->line);
free(dl->name);
if (dl->ins && dl->ins->ops == &lock_ops) {
free(dl->ops.locked.ops);
} else {
free(dl->ops.source.raw);
free(dl->ops.source.name);
}
free(dl->ops.target.raw);
free(dl->ops.target.name);
if (dl->ins && dl->ins->ops->free)
dl->ins->ops->free(&dl->ops);
else
ins__delete(&dl->ops);
free(dl);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/annotate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct ins_operands {
};

struct ins_ops {
void (*free)(struct ins_operands *ops);
int (*parse)(struct ins_operands *ops);
int (*scnprintf)(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops);
Expand Down

0 comments on commit cc1a381

Please sign in to comment.