Malcolm McLean wrote, On 17/06/07 22:40:
Malcolm McLean wrote:
Malcolm McLean said:
<snip>
There quite a strong case for a safemalloc() library function that
does terminate with an error message on fail.
No, there isn't. Library routines have no business deciding to
terminate
the program.
The problem is that the code is disproprtionate. [...]
[code snipped; see up-thread]
Should fprintf() halt the program on an I/O error?
Should fopen() halt the program if unable to open the file?
Should strtod() halt the program on a malformed input?
Then why should malloc() halt the program on a whim?
The Turing machine has run out of tape. That's a different kind of
problem to the others you have described.
It is a recoverable error in many situations just as all the others
are. For example, when stressing my company notebook several times
I've had VMware tell me it was out of memory giving the option to
retry. I closed down some other stuff, told it to retry, and continued
with my work. Far better than your approach of having it die on me.