diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-12-04 16:01:20 +0000 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-12-04 16:01:20 +0000 |
commit | cd40ed22216a95967662819c7a9f9ad69fc09abd (patch) | |
tree | 347a552e27ce91b25165182471ad7214ad9b1ff3 /day3.c | |
parent | 50a873db767f62befc8dc9b7abb96018bdb84d61 (diff) |
Free those arrays!
Diffstat (limited to 'day3.c')
-rw-r--r-- | day3.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -11,10 +11,10 @@ int** make2dWithOffset(int rows, int cols, int roff, int coff) { return (arr + roff); } -void free2dWithOffset(int** arr, int rows, int roff) { +void free2dWithOffset(int** arr, int rows, int roff, int coff) { int i; for(i = -roff; i < rows - roff ; i++) - free(arr[i]); + free(arr[i] - coff); free(arr - roff); } @@ -79,6 +79,9 @@ int main() { rssum++; } + free2dWithOffset(somap, 400, 200, 200); + free2dWithOffset(rsmap, 400, 200, 200); + printf("Santa only: %d\nRobosanta: %d\n", sosum, rssum); return 0; } |