diff options
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,13 +1,15 @@ #include "match.h" #include <stdlib.h> +#include <string.h> struct leg *leg_init(int points, char *name) { struct leg *l = calloc(1, sizeof(*l)); l->name = name; l->start = l->rem = points; - l->visits = calloc(1000, sizeof(*(l->visits))); // FIXME + l->size_visits = 16; + l->visits = calloc(l->size_visits, sizeof(*(l->visits))); return l; } @@ -23,3 +25,12 @@ void leg_free(struct leg *l) 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); +} |