On Thu Sep 14 17:44:20 2023 +0000, Zebediah Figura wrote:
The static variable feels brittle to me; I guess there's no reason it doesn't work but if it were up to me I'd still prefer to avoid it. If it were me I'd just embed all the array parameters in a struct and pass that down. I think in general what you're calling "pos" and "count", I'm used to calling "count" and "capacity".
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.