next up previous
Next: malloc() never returns NULL, Up: Frequently Asked Questions Previous: Frequently Asked Questions

Does malloc() really never returns NULL?

Yes! If an allocation cannot take place in true memory or in swap files, the module will call exit() and never return. You can safely call malloc() without fear of getting a NULL pointer back.

Do not forget that the module extends the amount of allocatable memory to the magic barrier of 2Gb or 4Gb on a 32-bit machine. When did you last need that much memory? :-)



Nicolas Devillard 2002-05-03