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 /block_placement_queries.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 'block_placement_queries.c')
-rw-r--r-- | block_placement_queries.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/block_placement_queries.c b/block_placement_queries.c index 3f244ed..358fd95 100644 --- a/block_placement_queries.c +++ b/block_placement_queries.c @@ -137,11 +137,12 @@ int main() { qcs1[i] = ARRAY_SIZE(q1i[i]); for (int i = 0; i < ARRAY_SIZE(q2i); i++) qcs2[i] = ARRAY_SIZE(q2i[i]); - struct two_d_arr q1, q2; - two_d_arr_init(&q1, ARRAY_SIZE(q1i), ARRAY_SIZE(q1i[0]), q1i); - two_d_arr_init(&q2, ARRAY_SIZE(q2i), ARRAY_SIZE(q2i[0]), q2i); - bool *gr1 = getResults(q1.arr, q1.row_size, qcs1, &rs1); - bool *gr2 = getResults(q2.arr, q2.row_size, qcs2, &rs2); + struct two_d_arr *q1 = + two_d_arr_init(ARRAY_SIZE(q1i), ARRAY_SIZE(q1i[0]), q1i); + struct two_d_arr *q2 = + two_d_arr_init(ARRAY_SIZE(q2i), ARRAY_SIZE(q2i[0]), q2i); + bool *gr1 = getResults(q1->arr, q1->row_size, qcs1, &rs1); + bool *gr2 = getResults(q2->arr, q2->row_size, qcs2, &rs2); for (int i = 0; i < rs1; i++) printf("%d ", gr1[i]); // expect: 0 1 1 printf("\n"); @@ -150,6 +151,6 @@ int main() { printf("\n"); free(gr1); free(gr2); - two_d_arr_free(&q1); - two_d_arr_free(&q2); + two_d_arr_free(q1); + two_d_arr_free(q2); } |