logoalt Hacker News

kvemkon • today at 1:41 PM • 1 reply • view on HN

> the program should check for a null pointer and gracefully exit if one is found: ...

If malloc() fails, there is no need to exit the program completely with exit(), only return from the current function with an error.


Replies

randomNumber7 • today at 2:38 PM

It is impractical to try to recover/continue your program in an out of memory situation for most programs.

So it is a good advice for beginners.

➕ show 3 replies