Re: Memory overcommitting (was Re: http://www.redhat.com/redhat/)

David Schwartz (davids@wiznet.net)
Thu, 20 Feb 1997 11:20:50 -0500 (EST)


On Thu, 20 Feb 1997, Tuukka Toivonen wrote:

> As I have understand, Linux returns ALWAYS success when using malloc(),
> because only reason why malloc() would fail, is memory overrun, and this
> will never happen in malloc().

Correct. Linux _always_ returns success in a malloc assuming the
parameters are reasonable.

> So my question is: is there any point in checking whether malloc() returned
> NULL (failure) or success? Should i just start using the memory without
> checking if the pointer is NULL?

I would still check, for two major reasons:

1) Someone might want to port your code to another platform whose
'malloc' implementation returns NULL under all sorts of circumstances.

2) Someone might link your code with a different 'malloc'
implementation that behaves differently.

DS

--------------------------------------------------------------------------
Jeane L. Dixon, world renowned psychic, died Saturday (1/25) at age 79.
There was almost universal sadness and lament throughout the world of
celebrity psychics. Contacted at her home, Dionne Warwick's spokeswoman
said that "[Miss] Warwick is beside herself -- none of us expected this to
happen".
--------------------------------------------------------------------------