xyarray.h 432 B

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