Oskar Liljeblad wrote:
> Here's what getdelim in Gnulib returns:
>   >=0, errno undefined, feof  (getc returned EOF, reached end of file)
>   >=0, errno!=0, ferror       (getc returned EOF, read failed)

Actually I think the glibc doc means that -1 is returned if EOF or read
failure occurs before the first character is read. If it occurs after
some non-empty string is already read, this non-empty string is returned.

>   -1, errno!=0                      (malloc failed, assuming malloc set errno)
>   -1, errno!=0                      (realloc failed, assuming realloc set 
> errno)

You cannot assume that malloc() and realloc() set errno upon failure.

  - In ISO C 99, the description of malloc() and realloc() does not mention
    errno. Also, <errno.h> is not required to declare a macro 'ENOMEM'.
  - Windows (mingw) malloc() and realloc() don't always set errno.

But on the other hand, malloc() and realloc() are free to modify errno
even when they succeed. (This happens e.g. on GNU/kFreeBSD, a glibc system.)

Bruno



_______________________________________________
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib

Reply via email to