This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: malloc failure and errno
- From: Bruno Haible <bruno at clisp dot org>
- To: Jim Meyering <jim at meyering dot net>
- Cc: bug-gnulib <bug-gnulib at gnu dot org>, libc-alpha at sourceware dot org
- Date: Sun, 9 Sep 2007 16:03:55 +0200
- Subject: Re: malloc failure and errno
- References: <46C74FCA.9090709@byu.net> <200708222325.47561.bruno@clisp.org> <87mywj8cow.fsf@rho.meyering.net>
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