to make the programs more efficient, do i need to free variables which are declared locally in the functions? Are they not disposed when the function ends?
serkan sendur 821 Postaholic Banned
Recommended Answers
Jump to PostYou only need to explicitly free resources that you explicitly ask for. For example, a FILE* given to you by fopen needs to be closed, and a pointer given to you by malloc needs to be freed.
Jump to PostIf you call malloc, then you need to call free.
The compiler looks after allocation and deallocation of local variables.
All 5 Replies
Narue 5,707 Bad Cop Team Colleague
Salem 5,138 Posting Sage
ddanbe 2,724 Professional Procrastinator Featured Poster
serkan sendur 821 Postaholic Banned
Narue 5,707 Bad Cop Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.