aboutsummaryrefslogtreecommitdiff
path: root/day3.c
diff options
context:
space:
mode:
authorNathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk>2015-12-04 16:01:20 +0000
committerNathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk>2015-12-04 16:01:20 +0000
commitcd40ed22216a95967662819c7a9f9ad69fc09abd (patch)
tree347a552e27ce91b25165182471ad7214ad9b1ff3 /day3.c
parent50a873db767f62befc8dc9b7abb96018bdb84d61 (diff)
Free those arrays!
Diffstat (limited to 'day3.c')
-rw-r--r--day3.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/day3.c b/day3.c
index 00dca81..7179be6 100644
--- a/day3.c
+++ b/day3.c
@@ -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;
}