The first one is obviously correct.
The second one, after fixing the typo, is equal to the first one plus a memory leak.
Please also refer to the functions contract for accessing all those strings, and for deallocation.
You probably get a NULL
-terminated array of 0
-terminated strings, but deallocation might be trickier.
Likely deallocation choices:
- Static data, trap for multithreading/recursion/multi-call trap, no explicit deallocation needed nor permissible.
- All in one block, only free the main pointer.
- Each component must be freed separately.