- Joined
- Mar 10, 2019
I assumed that he knew this, but yeah, it's worth mentioning.It's pretty rare, butmalloc
can fail to allocate memory. If any problems do arise,malloc
and co. will return aNULL
pointer; be sure to check your pointer isn'tNULL
before 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.