xyarray.c 364 B

123456789101112131415161718192021
  1. #include "xyarray.h"
  2. #include "util.h"
  3. struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
  4. {
  5. size_t row_size = ylen * entry_size;
  6. struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size);
  7. if (xy != NULL) {
  8. xy->entry_size = entry_size;
  9. xy->row_size = row_size;
  10. }
  11. return xy;
  12. }
  13. void xyarray__delete(struct xyarray *xy)
  14. {
  15. free(xy);
  16. }