On Fri Sep 15 16:11:00 2023 +0000, Fabian Maurer wrote:
Sure, I pushed a rework. IMHO I found a pretty clean solution, although memory management combined with recursion is kinda tricky, so would you mind double checking I didn't miss an edgecase? I made it so the struct is cleaned before/after use and possibly reused. The array is only allocated once it's needed, and when the last recursion finishes it's freed again. I didn't want to allocate/free the array outside of the functions, I believe it's cleaner this way.
I would just use a separate wrapper function to call the base case, and free the array from there, rather than decrementing count like that. That's what I see more often so I'd call it more idiomatic.
A more minor comment, but those various "int" variables should really be unsigned.