| @node strncpy | |
| @subsection @code{strncpy} | |
| @findex strncpy | |
| POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/strncpy.html} | |
| Gnulib module: string-h or strncpy | |
| @mindex string-h | |
| @mindex strncpy | |
| Portability problems fixed by Gnulib module @code{string-h} or Gnulib module @code{strncpy}: | |
| @itemize | |
| @item | |
| This function cannot be called from plain inline or extern inline functions | |
| on some platforms: | |
| macOS 10.8. | |
| @end itemize | |
| Portability problems fixed by Gnulib module @code{strncpy}: | |
| @itemize | |
| @item | |
| This function looks at more bytes of the source string than allowed | |
| on some platforms: | |
| @c https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291359 | |
| FreeBSD 15.0/x86_64. | |
| @end itemize | |
| Portability problems not fixed by Gnulib: | |
| @itemize | |
| @end itemize | |
| Note: This function was designed for the use-case of filling a fixed-size | |
| record with a string, before writing it to a file. This function is | |
| @strong{not} appropriate for copying a string into a bounded memory area, | |
| because you have no guarantee that the result will be NUL-terminated. | |
| Even if you add the NUL byte at the end yourself, this function is | |
| inefficient (as it spends time clearing unused memory) and will allow | |
| silent truncation to occur, which is not a good behavior for GNU programs. | |
| For more details, see @url{https://meyering.net/crusade-to-eliminate-strncpy/}. |