correct grid malloc to calloc

This commit is contained in:
Tiehuis 2014-12-06 12:58:29 +13:00
parent b7c45f7f87
commit 44bc1cbe87

View File

@ -190,12 +190,12 @@ struct gamestate* gamestate_init(struct gameoptions *opt)
//long *grid_back = malloc(opt->grid_width * opt->grid_height * sizeof(long)); //long *grid_back = malloc(opt->grid_width * opt->grid_height * sizeof(long));
//if (!grid_back) goto grid_back_alloc_fail; //if (!grid_back) goto grid_back_alloc_fail;
g->grid = malloc(opt->grid_width * sizeof(long*)); g->grid = malloc(opt->grid_width, sizeof(long*));
if (!g->grid) goto grid_alloc_fail; if (!g->grid) goto grid_alloc_fail;
int i; int i;
for (i = 0; i < opt->grid_height; ++i) for (i = 0; i < opt->grid_height; ++i)
g->grid[i] = malloc(opt->grid_height * sizeof(long)); g->grid[i] = calloc(opt->grid_height, sizeof(long));
g->moved = 0; g->moved = 0;
g->score = 0; g->score = 0;