5 Jun
2012
5 Jun
'12
9:50 a.m.
Jorge Arellano Cid wrote:
Some C libs leave errno unset, and others always set it to ENOMEM. Please excuse my ignorance, but what other error conditions may malloc return?
According to the man pages on my Linux system: The Unix98 standard requires malloc(), calloc(), and realloc() to set errno to ENOMEM upon failure. Glibc assumes that this is done (and the glibc versions of these routines do this); if you use a private malloc implementation that does not set errno, then certain library routines may fail with- out having a reason in errno. So, unless we support systems that do not conform to Unix98, then I read this as saying that ENOMEM is the only error we will see. Regards, Jeremy Henty