aboutsummaryrefslogtreecommitdiff
path: root/map_highest_peak.c
diff options
context:
space:
mode:
Diffstat (limited to 'map_highest_peak.c')
-rw-r--r--map_highest_peak.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/map_highest_peak.c b/map_highest_peak.c
index d98e563..e9e143b 100644
--- a/map_highest_peak.c
+++ b/map_highest_peak.c
@@ -83,12 +83,13 @@ int **highestPeak(int **isWater, int isWaterSize, int *isWaterColSize,
int main() {
int iw1i[2][2] = {{0, 1}, {0, 0}},
iw2i[3][3] = {{0, 0, 1}, {1, 0, 0}, {0, 0, 0}};
- struct two_d_arr iw1, iw2;
- two_d_arr_init(&iw1, ARRAY_SIZE(iw1i), ARRAY_SIZE(iw1i[0]), iw1i);
- two_d_arr_init(&iw2, ARRAY_SIZE(iw2i), ARRAY_SIZE(iw2i[0]), iw2i);
+ struct two_d_arr *iw1 =
+ two_d_arr_init(ARRAY_SIZE(iw1i), ARRAY_SIZE(iw1i[0]), iw1i);
+ struct two_d_arr *iw2 =
+ two_d_arr_init(ARRAY_SIZE(iw2i), ARRAY_SIZE(iw2i[0]), iw2i);
int rs1, rs2, *rcs1, *rcs2;
- int **hp1 = highestPeak(iw1.arr, iw1.row_size, iw1.col_size, &rs1, &rcs1);
- int **hp2 = highestPeak(iw2.arr, iw2.row_size, iw2.col_size, &rs2, &rcs2);
+ int **hp1 = highestPeak(iw1->arr, iw1->row_size, iw1->col_size, &rs1, &rcs1);
+ int **hp2 = highestPeak(iw2->arr, iw2->row_size, iw2->col_size, &rs2, &rcs2);
for (int i = 0; i < rs1; i++) {
for (int j = 0; j < rcs1[i]; j++)
printf("%d ", hp1[i][j]); // expect: 1 0 2 1
@@ -105,10 +106,10 @@ int main() {
free(hp1[i]);
free(hp1);
free(rcs1);
- two_d_arr_free(&iw1);
+ two_d_arr_free(iw1);
for (int i = 0; i < rs2; i++)
free(hp2[i]);
free(hp2);
free(rcs2);
- two_d_arr_free(&iw2);
+ two_d_arr_free(iw2);
}