#include "match.h" #include #include struct leg *leg_init(int points, char *name) { struct leg *l = calloc(1, sizeof(*l)); l->name = name; l->start = l->rem = points; l->size_visits = 16; l->visits = calloc(l->size_visits, sizeof(*(l->visits))); return l; } void leg_free(struct leg *l) { for (int i = 0; i < l->n_visits; ++i) { if (l->visits[i].darts) free(l->visits[i].darts); if (l->visits[i].ccoords) free(l->visits[i].ccoords); } free(l->visits); free(l); } void leg_grow_visits(struct leg *l) { size_t bytes = l->size_visits * sizeof(*(l->visits)); l->size_visits *= 2; l->visits = realloc(l->visits, 2 * bytes); memset((char *)l->visits + bytes, 0, bytes); }