xyarray.h 674 B

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