diff --git a/2015_day_3/day_3.c b/2015_day_3/day_3.c index 4c52e47..2fb59e8 100644 --- a/2015_day_3/day_3.c +++ b/2015_day_3/day_3.c @@ -76,12 +76,15 @@ void movenorth(Housearray* f, char direction){ //update y coordinate f->y·coord--; //check if expansion needed - if (f->y·coord < 0){ + if (f->y·coord - f->y_coord_origin < 0){ //Expand north int new_rows = old_rows +1; int new_cols = old_cols; //creates am array of pointers to point to my rows of integers int** new_grid = (int**)malloc(new_rows * sizeof(int*)); + if (new_grid == NULL){ + return; + } for (int i = 0; i< old_rows; ++i){ new_grid[i+1] = f->houses[i];//repeat without the plus one for the southward add row }