ANSI C Dynamic Memory Allocation and when exactly we should free the memory
问题 I am trying to get my head around memory allocations and freeing them in ANSI C. The problem is I don't know when to free them. 1) Does program exit free the allocated memory itself (even if I didn't do it by free() )? 2) Let's say my code is something like this: (please don't worry about the full code of those structs at the moment. I am after the logic only) snode = (stock_node *) realloc(snode, count * sizeof(stock_node)); struct stock_list slist = { snode, count }; stock_list_ptr slist