Newer
Older
#include <stdlib.h>
#include <stdio.h>
extern void chunk_info_init(chunk_info_t *ci, int type, const int dimensions[2], int y, int x, bool allocate_data) {
ci->dimensions[0] = dimensions[0];
ci->dimensions[1] = dimensions[1];
ci->count = (size_t) ci->dimensions[0] * (size_t) ci->dimensions[1];
ci->y = y;
ci->x = x;
}
extern void chunk_info_allocate_data(chunk_info_t *ci, size_t type) {
ci->data = calloc(ci->count, type);
assert(ci->data != NULL);
void chunk_info_print(chunk_info_t *ci) {
printf("[chunk_info_t] data = %p, dimensions = [%d][%d], count = %zu, YX = (%d, %d)\n",
ci->data, ci->dimensions[0], ci->dimensions[1], ci->count, ci->y, ci->x);
}
extern void chunk_info_free(chunk_info_t *ci) {
free(ci->data);
}