]> git.ipfire.org Git - thirdparty/man-pages.git/commit
getline.3: !*lineptr is sufficient
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Sat, 12 Jun 2021 08:27:39 +0000 (10:27 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sun, 20 Jun 2021 03:49:02 +0000 (15:49 +1200)
commit8b97c4f8754f420fd1bd5051d300a7eca09e514d
tree30718664ae7276ccebd62a1736f0c2288d82c40d
parente4728a856689d7e69bf9ebf8e4c82b6dea8a54fe
getline.3: !*lineptr is sufficient

No implementation or spec requires *n to be 0 to allocate a new buffer:
  * musl checks for !*lineptr
    (and sets *n=0 for later allocations)
  * glibc checks for !*lineptr || !*n
    (but only because it allocates early)
  * NetBSD checks for !*lineptr
    (and sets *n=0 for later allocations)
    (but specifies *n => mlen(*lineptr) >= *n as a precondition,
     to which this appears to be an exception)
  * FreeBSD checks for !*lineptr and sets *n=0
    (and specifies !*lineptr as sufficient)
  * Lastly, POSIX.1-2017 specifies:
    > If *n is non-zero, the application shall ensure that *lineptr
    > either points to an object of size at least *n bytes,
    > or is a null pointer.

The new wording matches POSIX, even if it arrives at the point slightly
differently

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/getline.3