An answer by user:surendra nath
on this post stated that the code posted by OP has a memory leak, whereas, most of the time I've come across that a leak occurs when we fail to free a dynamically allocated memory region but I couldn't see any dynamic allocation in OPs code.
He quoted this wiki definition, here.
And another definition of Memory Leak from user:artificial idiot
to post was:
Subtle definition: Failure to release reachable memory which is no longer needed for your program to function correctly. This is nearly impossible to detect with automated tools or by programmers who are not familiar with the code. While technically it is not a leak, it has the same implications as the naive one. This is not my own idea only. You can come across projects that are written in a garbage collected language but still mention fixing memory leaks in their changelogs.
So, my question:
- Is the point stated by "surendra nath" on OPs code, can be said as a memory leak considering the definition of a memory leak given by "artificial idiot" or wikipedia? And if so, then why?
- Does the memory leak in C always refer to the failure to free a previously dynamically allocated memory?
P.S. - I don't know if the definitions from wiki & "artificial idiot" have the same meaning, since wiki definitions are sometimes too broad to understand.