8 * Implements a linear search.
10 int gol_is_live(struct gol_board *const state, int_least32_t x, int_least32_t y,
13 for (unsigned int i = 0; i < state->n; i += 2) {
14 if (state->live_cells[i] == x &&
15 state->live_cells[i+1] == y) {
25 * Return values of 0 represent irrecoverable errors. 1 is a success.
27 int gol_vivify(struct gol_board *const state, int_least32_t x, int_least32_t y)
29 int_least32_t *tmp_cells = NULL;
32 if (state->n == state->size) {
33 tmp_size = 2 * state->size;
34 tmp_cells = malloc(tmp_size * sizeof(int_least32_t));
38 memcpy(tmp_cells, state->live_cells,
39 state->size * sizeof(int_least32_t));
40 state->size = tmp_size;
41 free(state->live_cells);
42 state->live_cells = tmp_cells;
45 state->live_cells[state->n] = x;
46 state->live_cells[state->n + 1] = y;
50 if (x > state->max_x) {
52 } else if (x < state->min_x) {
56 if (y > state->max_y) {
58 } else if (y < state->min_y) {