xyarray.h 713 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PERF_XYARRAY_H_
  3. #define _PERF_XYARRAY_H_ 1
  4. #include <sys/types.h>
  5. struct xyarray {
  6. size_t row_size;
  7. size_t entry_size;
  8. size_t entries;
  9. size_t max_x;
  10. size_t max_y;
  11. char contents[];
  12. };
  13. struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
  14. void xyarray__delete(struct xyarray *xy);
  15. void xyarray__reset(struct xyarray *xy);
  16. static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
  17. {
  18. return &xy->contents[x * xy->row_size + y * xy->entry_size];
  19. }
  20. static inline int xyarray__max_y(struct xyarray *xy)
  21. {
  22. return xy->max_y;
  23. }
  24. static inline int xyarray__max_x(struct xyarray *xy)
  25. {
  26. return xy->max_x;
  27. }
  28. #endif /* _PERF_XYARRAY_H_ */