Str.strlcpy

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, g_strdup() is an even better idea.

struct Str
static
size_t
strlcpy
(
string dest
,
string src
,
size_t destSize
)

Parameters

dest string

destination buffer

src string

source buffer

destSize size_t

length of @dest in bytes

Return Value

Type: size_t

length of @src

Meta