2 ms·
So, what’s the alternative? Not freeing resources is a very common error; it would be nice if the compiler could help detecting it. A possible explicit solutio
by Someone 6y ago
So, what’s the alternative? Not freeing resources is a very common error; it would be nice if the compiler could help detecting it.
A possible explicit solution I can think of is to introduce a new function attribute that gives the name of their ‘cleanup’ function (so that the compiler would know fopen needs a fclose, for example) and a compiler that uses these attributes to issue a warning if a function has a path that calls a function and doesn’t either call its cleanup function or returns its result.
I don’t know whether that would cover all bases, though.