aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-06-14 04:19:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-16 09:34:39 -0400
commitb45f65e8fddc89ac6b46388908d3f6ac728be372 (patch)
tree00c67bd22d4adc6aeabeb30eb7be4ddf5c85527c
parentba7ecb02e7b89b09d8cdf4c1514a386af8916c4b (diff)
perf tools: Introduce xyarray__reset function
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>
-rw-r--r--tools/perf/util/xyarray.c8
-rw-r--r--tools/perf/util/xyarray.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c
index 22afbf6c536a..c10ba41ef3f6 100644
--- a/tools/perf/util/xyarray.c
+++ b/tools/perf/util/xyarray.c
@@ -9,11 +9,19 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
9 if (xy != NULL) { 9 if (xy != NULL) {
10 xy->entry_size = entry_size; 10 xy->entry_size = entry_size;
11 xy->row_size = row_size; 11 xy->row_size = row_size;
12 xy->entries = xlen * ylen;
12 } 13 }
13 14
14 return xy; 15 return xy;
15} 16}
16 17
18void xyarray__reset(struct xyarray *xy)
19{
20 size_t n = xy->entries * xy->entry_size;
21
22 memset(xy->contents, 0, n);
23}
24
17void xyarray__delete(struct xyarray *xy) 25void xyarray__delete(struct xyarray *xy)
18{ 26{
19 free(xy); 27 free(xy);
diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h
index c488a07275dd..7f30af371b7e 100644
--- a/tools/perf/util/xyarray.h
+++ b/tools/perf/util/xyarray.h
@@ -6,11 +6,13 @@
6struct xyarray { 6struct xyarray {
7 size_t row_size; 7 size_t row_size;
8 size_t entry_size; 8 size_t entry_size;
9 size_t entries;
9 char contents[]; 10 char contents[];
10}; 11};
11 12
12struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size); 13struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
13void xyarray__delete(struct xyarray *xy); 14void xyarray__delete(struct xyarray *xy);
15void xyarray__reset(struct xyarray *xy);
14 16
15static inline void *xyarray__entry(struct xyarray *xy, int x, int y) 17static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
16{ 18{