I have a function that takes a pointer to a char ** and fills it with strings (an array of strings I guess). *list_of_strings* is allocated memory inside the function.
Yes, you have to free()
every block you obtained from malloc()
. You do it by traversing the array of pointers and caling free()
on each element and only then freeing the array itself.
Only you know that there's a tree-like structure that could be freed recursively, that knowledge is not anywhere in the C runtime heap, so the heap manager has no idea about that and your program has to free everything itself.