/* TODO: I suppose a lot of this stuff goes in the README instead. */
/* TODO: Explain the data structures in detail. */
/* TODO: Explain all the options, like the various starting conditions. */
/* TODO: I suppose a lot of this stuff goes in the README instead. */
/* TODO: Explain the data structures in detail. */
/* TODO: Explain all the options, like the various starting conditions. */
/* TODO: Check manpage for all functions I use and ensure my includes are correct. I don't want to depend on picking up includes via screenhack.h. */
/* TODO: Verify everything in this file is C89. Get rid of things like '//' comments, pack all my declarations upfront, no stdint, etc. */
/* TODO: Check manpage for all functions I use and ensure my includes are correct. I don't want to depend on picking up includes via screenhack.h. */
/* TODO: Verify everything in this file is C89. Get rid of things like '//' comments, pack all my declarations upfront, no stdint, etc. */
// (the two options above only apply to the simulation under the -rule-random or -rule N options. in curated mode, starting population is defined in the curation array)
// TODO: In the future, add the option for user to pass list of cell IDs to turn ON.
// size of pixel square (e.g. 1x1, 2x2, 3x3, etc)
// (the two options above only apply to the simulation under the -rule-random or -rule N options. in curated mode, starting population is defined in the curation array)
// TODO: In the future, add the option for user to pass list of cell IDs to turn ON.
// size of pixel square (e.g. 1x1, 2x2, 3x3, etc)
- struct state * state = calloc(1, sizeof(*state)); // TODO: Check calloc() call
+ struct state * state = calloc(1, sizeof(*state));
+ if (!state) {
+ fprintf(stderr, "ERROR: Failed to calloc() for state struct in WolframAutomata_init().\n");
+ exit(EXIT_FAILURE);
+ }
+
if (state->population_density < 0 || state->population_density > 100) state->population_density = 50;
state->current_generation = calloc(1, sizeof(*state->current_generation)*state->number_of_cells);
if (!state->current_generation) {
if (state->population_density < 0 || state->population_density > 100) state->population_density = 50;
state->current_generation = calloc(1, sizeof(*state->current_generation)*state->number_of_cells);
if (!state->current_generation) {