There is no garbage collection in C!
You should read a book about C: The Definitive C Book Guide and List, specifically about pointers, the heap and the stack.
If you malloc
a section of memory, the pointers live on the heap, and will not disappear or "become unusable" until free is called on that pointer. It has nothing to do with the scope of a function, which is also called a stack frame. If you declared an array of a fixed size on the stack then it would go out of scope once that stack unwinds.
In short, your last sentence is correct, if you use malloc, the memory will be allocated on the heap until you call free.