Arnaldo Carvalho de Melo | 69aad6f | 2011-01-03 16:39:04 -0200 | [diff] [blame] | 1 | #ifndef _PERF_XYARRAY_H_ |
| 2 | #define _PERF_XYARRAY_H_ 1 |
| 3 | |
| 4 | #include <sys/types.h> |
| 5 | |
| 6 | struct xyarray { |
| 7 | size_t row_size; |
| 8 | size_t entry_size; |
Jiri Olsa | b45f65e | 2015-06-14 10:19:16 +0200 | [diff] [blame^] | 9 | size_t entries; |
Arnaldo Carvalho de Melo | 69aad6f | 2011-01-03 16:39:04 -0200 | [diff] [blame] | 10 | char contents[]; |
| 11 | }; |
| 12 | |
| 13 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size); |
| 14 | void xyarray__delete(struct xyarray *xy); |
Jiri Olsa | b45f65e | 2015-06-14 10:19:16 +0200 | [diff] [blame^] | 15 | void xyarray__reset(struct xyarray *xy); |
Arnaldo Carvalho de Melo | 69aad6f | 2011-01-03 16:39:04 -0200 | [diff] [blame] | 16 | |
| 17 | static inline void *xyarray__entry(struct xyarray *xy, int x, int y) |
| 18 | { |
| 19 | return &xy->contents[x * xy->row_size + y * xy->entry_size]; |
| 20 | } |
| 21 | |
| 22 | #endif /* _PERF_XYARRAY_H_ */ |