On Sun, Nov 08, 2015 at 08:36:52AM +0000, Nicholas Marriott wrote: > On Sat, Nov 07, 2015 at 08:42:14PM -0500, Ted Unangst wrote: > > Tobias Stoeckmann wrote: > > > Is this okay for ssh and tmux, which are out to be very portable? > > > Nicholas mentioned that malloc is not required to set errno. I've also > > > checked the standard and it's just an extension. Although at worst, > > > the user sees a wrong error message... > > > > Are they portable to not-posix? posix dictates that malloc set errno. > > It is optional in SUSv3: > > RETURN VALUE > > Upon successful completion with size not equal to 0, malloc() shall > return a pointer to the allocated space. If size is 0, either > a null pointer or a unique pointer that can be successfully > passed to free() shall be returned. Otherwise, it shall return > a null pointer ^[CX] [Option Start] and set errno to indicate > the error. [Option End]
Not really, that just means that the "and set errno" part is not included in ISO C itself. The markup is a bit confusing, but CX is not an option in the "pick it or not sense". Joerg