diff options
author | Jack Sangdahl <[email protected]> | 2025-08-27 12:45:33 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-08-27 12:45:33 -0600 |
commit | 4552bcf5a4a356415e248dee3b201f0cea7205bb (patch) | |
tree | 9868465918c6a6841b84cd14d66923b993dd9d62 /dungeon_game.c | |
parent | f549305fb5ca531d29dce6c2c091560f44190443 (diff) | |
download | leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.tar.gz leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.zip |
chore: Refactor two_d_arr_init function
Return a pointer to a new struct, rather than initialise objects in an
existing struct
Diffstat (limited to 'dungeon_game.c')
-rw-r--r-- | dungeon_game.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/dungeon_game.c b/dungeon_game.c index 6a54e5d..2bb2543 100644 --- a/dungeon_game.c +++ b/dungeon_game.c @@ -38,13 +38,12 @@ int calculateMinimumHP(int **dungeon, int dungeonSize, int *dungeonColSize) { int main() { int d1i[3][3] = {{-2, -3, 3}, {-5, -10, 1}, {10, 30, -5}}, d2i[1][1] = {{0}}; - struct two_d_arr d1, d2; - two_d_arr_init(&d1, 3, 3, d1i); - two_d_arr_init(&d2, 1, 1, d2i); + struct two_d_arr *d1 = two_d_arr_init(3, 3, d1i); + struct two_d_arr *d2 = two_d_arr_init(1, 1, d2i); printf("%d\n", - calculateMinimumHP(d1.arr, d1.row_size, d1.col_size)); // expect: 7 + calculateMinimumHP(d1->arr, d1->row_size, d1->col_size)); // expect: 7 printf("%d\n", - calculateMinimumHP(d2.arr, d2.row_size, d2.col_size)); // expect: 1 - two_d_arr_free(&d1); - two_d_arr_free(&d2); + calculateMinimumHP(d2->arr, d2->row_size, d2->col_size)); // expect: 1 + two_d_arr_free(d1); + two_d_arr_free(d2); } |