4 ms·
I want this feature in the standard. If there exists any memory block allocated using malloc() / calloc() / realloc() which has not been free()'d, at the end o
by smlckz 7y ago
I want this feature in the standard.
If there exists any memory block allocated using malloc() / calloc() / realloc() which has not been free()'d, at the end of the program, they would be free()'d automatically.
One can easily do it with keeping a linked list and using atexit(), but, can it be added to the standard?
A general question, will anything, any feature, which is "easy" to implement in pure C, like array knowing its own length or pascal strings, NOT be allowed to be in C standard, even if it is widely used, maybe almost everywhere?
- bch 7y agoThe operating system handles this for you on process deletion. Lots of “one shot” programs count on this (and (e.g.) file descriptors being automatically closed).
- smlckz 7y agoSo, should I not care about that so much, and write programs without free()'ing allocated memory? If OSes do that, why not standardize that in C?