/* 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: Explain all the dependencies like libXpm. */
+/* TODO: Add a #define for the hack version. */
/* 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. */
// Command line options
// directory to output XBM files of each run (and call an external command to convert to PNGs?)
// -save-dir STRING
+// (could use libXpm to save an XPM and then convert to PNG with ImageMagick) (this is a single function call to go from pixmap -> file)
+// (since it depends on an external library, make this whole feature optional at build-time?)
// number of generations to simulate
+// -random-generations
// -num-generations N
// delay time (speed of simulation)
+// -random-delay
// -delay-usec N
// foreground and background color
// -random-colors (highest precedence)
// (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)
+// -random-pixel-size
// -pixel-size N
/* -------------------------------------------------------------------------- */
static void *
WolframAutomata_init(Display * dpy, Window win)
{
- 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);
+ }
+
XGCValues gcv;
XWindowAttributes xgwa;
const struct curated_ruleset * curated_ruleset = NULL;
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) {
- fprintf(stderr, "ERROR: Failed to calloc() in WolframAutomata_init().\n");
+ fprintf(stderr, "ERROR: Failed to calloc() for cell generation in WolframAutomata_init().\n");
exit(EXIT_FAILURE);
}
if (curated_ruleset) {