malloc failure and errno
Bruno Haible
bruno@clisp.org
Sun Sep 9 14:04:00 GMT 2007
Jim Meyering wrote:
> POSIX guarantees that errno is defined when malloc or realloc
> fails, so there's no need to set it manually in that case.
Yet glibc does set it manually in some cases:
glibc-2.6.1/login/openpty.c:69
glibc-2.6.1/login/login.c:67
glibc-2.6.1/stdlib/setenv.c:180
glibc-2.6.1/sysdeps/unix/grantpt.c:82
What is the reason? Can malloc() return NULL with errno being set to something
different than ENOMEM?
Bruno
More information about the Libc-alpha
mailing list