Sujet : Re: C23 thoughts and opinions - why so conservative?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.cDate : 25. May 2024, 01:31:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2rbg7$2i5ih$3@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Pan/0.155 (Kherson; fc5a80b8)
On Fri, 24 May 2024 07:47:48 +0100, Malcolm McLean wrote:
I virtually always use goto for memory allocation failure.
It does mean that, strictly, the function is no longer a "structured"
subroutine. But reality is usually that memory allocation failure will
mean program termination pretty soon.
Hmm, there may be a point in that. Consider also that Linux systems are
typically configured to overcommit memory allocations: they never say
“no”, but when they start running low, then they start killing the big
memory hogs.
However, there are other dynamic checks that may need to be done. For
example, trying to load an image, and discovering that your decoder cannot
handle it, possibly because it is corrupted or the wrong format
altogether. It would be nice to recover gracefully from this sort of
situation. And not have the decoder crash or leak memory.