Nitpick: it’s not quite a drop-in. Prototypes of these functions are
char * strncpy(char *dst, const char *src, size_t num); size_t strlcpy(char *dst, const char *src, size_t num);
strlcpy(dst, src, num) returns the total length of the string it tried to create (https://www.unix.com/man-page/posix/3/strlcpy/). Callers can use that to detect that the string didn’t fit the buffer and reallocate a buffer that’s long enough.
Nitpick: it’s not quite a drop-in. Prototypes of these functions are
strncpy(dst, src, num) always returns dst (https://cplusplus.com/reference/cstring/strncpy/), which is quite useless, as the caller knew that already.strlcpy(dst, src, num) returns the total length of the string it tried to create (https://www.unix.com/man-page/posix/3/strlcpy/). Callers can use that to detect that the string didn’t fit the buffer and reallocate a buffer that’s long enough.