xyarray.h 490 B

12345678910111213141516171819202122
  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. char contents[];
  9. };
  10. struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
  11. void xyarray__delete(struct xyarray *xy);
  12. void xyarray__reset(struct xyarray *xy);
  13. static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
  14. {
  15. return &xy->contents[x * xy->row_size + y * xy->entry_size];
  16. }
  17. #endif /* _PERF_XYARRAY_H_ */