An interesting point arose with some of my colleagues, some of whom claim that you always need a freememory, that you are mallocunimportant. Although I always thought it was good practice overall, some others argued that it was not necessary in a program such as:
#include <stdio.h>
#include <stdlib.h>
int main (void) {
char *mem = malloc (1000);
if (mem != NULL) {
}
return 0;
}
Their statement was that the memory will be cleared when the process is complete.
Now, being the local standard uber-geek, they turned to me for clarification and, to my surprise, it seems that always a free crowd can really be right.
Turning to C11, 5.1.2.2.3 Program terminationhe simply claims that reaching the end is mainidentical to the challenge exit.
7.22.4.4 The exit function lists those things that are cleaned, in particular:
.
, 6.2.4 Storage duration of objects, , "" . , :
7.22.3.
7.22.3 Memory management functions , malloc free. , , . :
.
, , - , , - , , . , ISO C.
- , " ", , , ( malloc, , , ).
, . ( ISO C), , , , ?
- , ?