J
Jens.Toerring
brian said:If the implementation follows the standards, the above is what I get
(that ENOMEN is set) from the malloc() man page in openBSD. However,
in the man page in linux, there was no mention of ENOMEM being set,
and I couldn't get malloc() to fail in linux even using setrlimit().
See the NOTES section of the Linux man page, it's mentioned there.
Regarding your problem to get malloc() to fail lets discuss this in
comp.os.linux.development.apps, you can definitely get it to fail.
Now, you have to test for how much the implementation follows any
standard and what standards are followed, which makes portability a pain.
And per the scope of this newsgroup, any extension of ISO C is off
topic. So if the C standard does not require malloc() to set errno,
then we have serious problems when testing for errors. We first
have to determine what standard is followed. We then have to re-write
our error code by implementation or use a lot of #ifndef #if . . .
I don't see why having errno set or not would be a problem at all -
just assume it won't get set and everything should be fine. There
isn't any additional information you get from checking errno you
don't already have when malloc() returns NULL.
Regards, Jens