perf xyarray: Save max_x, max_y
authorAndi Kleen <ak@linux.intel.com>
Fri, 11 Aug 2017 23:26:16 +0000 (16:26 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 22 Aug 2017 14:51:28 +0000 (11:51 -0300)
Save the original array dimensions in xyarrays, so that users can
retrieve them later. Add some inline functions to access these fields.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170811232634.30465-1-andi@firstfloor.org
[ As noticed by Jiri, fix up namespacing: xy__method() -> xyarray__method() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/xyarray.c
tools/perf/util/xyarray.h

index 7251fdbabceda5e0bb88e4b9ae83f501ea9ad517..c8f415d9877b08503d12e10e1bb0fe463c81e6f1 100644 (file)
@@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
                xy->entry_size = entry_size;
                xy->row_size   = row_size;
                xy->entries    = xlen * ylen;
+               xy->max_x      = xlen;
+               xy->max_y      = ylen;
        }
 
        return xy;
index 7f30af371b7ee692f23b9bf4aeb354584f453722..4ba726c9087072184b445ddc4e788d7000ade01d 100644 (file)
@@ -7,6 +7,8 @@ struct xyarray {
        size_t row_size;
        size_t entry_size;
        size_t entries;
+       size_t max_x;
+       size_t max_y;
        char contents[];
 };
 
@@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
        return &xy->contents[x * xy->row_size + y * xy->entry_size];
 }
 
+static inline int xyarray__max_y(struct xyarray *xy)
+{
+       return xy->max_x;
+}
+
+static inline int xyarray__max_x(struct xyarray *xy)
+{
+       return xy->max_y;
+}
+
 #endif /* _PERF_XYARRAY_H_ */