7 * Implements a linear search.
9 int gol_is_live(struct gol_board *const state, int_least32_t x, int_least32_t y)
11 for (unsigned int i = 0; i < state->n; i += 2) {
12 if (state->live_cells[i] == x &&
13 state->live_cells[i+1] == y) {
20 int gol_vivify(struct gol_board *const state, int_least32_t x, int_least32_t y)
22 int_least32_t *tmp_cells = NULL;
24 if (state->n == state->size) {
25 tmp_size = 2 * state->size;
26 tmp_cells = malloc(tmp_size * sizeof(typeof(tmp_cells)));
30 memcpy(tmp_cells, state->live_cells,
31 tmp_size * sizeof(typeof(tmp_cells)));
32 state->size = tmp_size;
33 free(state->live_cells);
34 state->live_cells = tmp_cells;
37 state->live_cells[state->n] = x;
38 state->live_cells[state->n + 1] = y;
42 if (x > state->max_x) {
44 } else if (x < state->min_x) {
48 if (y > state->max_y) {
50 } else if (y < state->min_y) {