Skip to content

Commit

Permalink
Made memory allocation more efficient.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhenriques committed Nov 1, 2020
1 parent 2442fb6 commit 1fdc36c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gol.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ p_universe * init_parallel_universes(int total_universes, int uni_cells) {

for( int i = 0; i < total_universes; i++ ) {
uni = malloc(sizeof(p_universe));
uni->cells = malloc(uni_cells * sizeof(char));
uni->cells = malloc((PANEL_W * PANEL_H) * sizeof(char));

randomize_universe(uni, uni_cells);

Expand Down Expand Up @@ -352,9 +352,10 @@ int main(int argc, char **argv) {

last_stuck_check = before;
last_reset = before;
destroy_parallel_universes(universe);
//destroy_parallel_universes(universe);
init_rand_context(&context);
universe = init_universes_w_context(&context);
//universe = init_universes_w_context(&context);
randomize_universe(universe, context.TOTAL_CELLS);
}

for (y = 0; y < PANEL_H; y++) {
Expand Down Expand Up @@ -387,3 +388,4 @@ int main(int argc, char **argv) {
return 0;
}


0 comments on commit 1fdc36c

Please sign in to comment.