Portability wrapper that calls strlcpy() on systems which have it,
and emulates strlcpy() otherwise. Copies src to dest; dest is
guaranteed to be nul-terminated; src must be nul-terminated;
dest_size is the buffer size, not the number of bytes to copy.
At most dest_size - 1 characters will be copied. Always nul-terminates
(unless dest_size is 0). This function does not allocate memory. Unlike
strncpy(), this function doesn't pad dest (so it's often faster). It
returns the size of the attempted result, strlen (src), so if
retval >= dest_size, truncation occurred.
Caveat: strlcpy() is supposedly more secure than strcpy() or strncpy(),
but if you really want to avoid screwups, GLib.strdup is an even better
idea.
Portability wrapper that calls
strlcpy()on systems which have it, and emulatesstrlcpy()otherwise. Copiessrctodest;destis guaranteed to be nul-terminated;srcmust be nul-terminated;dest_sizeis the buffer size, not the number of bytes to copy.At most
dest_size- 1 characters will be copied. Always nul-terminates (unlessdest_sizeis 0). This function does not allocate memory. Unlikestrncpy(), this function doesn't paddest(so it's often faster). It returns the size of the attempted result,strlen (src), so ifretval>=dest_size, truncation occurred.Caveat:
strlcpy()is supposedly more secure thanstrcpy()orstrncpy(), but if you really want to avoid screwups, GLib.strdup is an even better idea.