Skip to content

Commit

Permalink
perf tools: Introduce xyarray__reset function
Browse files Browse the repository at this point in the history
To zero all the xyarray contents. It will be used in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434269985-521-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Jun 16, 2015
1 parent ba7ecb0 commit b45f65e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/perf/util/xyarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
if (xy != NULL) {
xy->entry_size = entry_size;
xy->row_size = row_size;
xy->entries = xlen * ylen;
}

return xy;
}

void xyarray__reset(struct xyarray *xy)
{
size_t n = xy->entries * xy->entry_size;

memset(xy->contents, 0, n);
}

void xyarray__delete(struct xyarray *xy)
{
free(xy);
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/xyarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
struct xyarray {
size_t row_size;
size_t entry_size;
size_t entries;
char contents[];
};

struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
void xyarray__delete(struct xyarray *xy);
void xyarray__reset(struct xyarray *xy);

static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
{
Expand Down

0 comments on commit b45f65e

Please sign in to comment.