- Joined
- Mar 10, 2019
I assumed that he knew this, but yeah, it's worth mentioning.It's pretty rare, butmalloccan fail to allocate memory. If any problems do arise,mallocand co. will return aNULLpointer; be sure to check your pointer isn'tNULLbefore proceeding with using the memory you tried to allocate.
If you're trying to allocate a huge chunk of memory and you fail, then yeah, it's probably appropriate to try to do something graceful about that. But depending on what you're doing, in some cases the only appropriate solution is to crash and burn spectacularly.