> 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().
That's wrong. Linux (since 2.0.x, 1.2.x didn't) uses a simple heuristic
to find out if enough memory is available. The other possibility is when
you run into your rlimits.
I really wish people would check the facts before posting.
overcom.c:
#include <stdlib.h>
main()
{
void *p;
p = malloc(1024 * 1024 * 1024); /* allocate 1GB */
printf("p = %p\n", p);
}
% ulimit -v
(unlimited)
% gcc -o overcom overcom.c
% ./overcom
(nil)
%
-Andi