Str.strlcat

Portability wrapper that calls strlcat() on systems which have it, and emulates it otherwise. Appends nul-terminated src string to dest, guaranteeing nul-termination for dest. The total size of dest won't exceed dest_size. At most dest_size - 1 characters will be copied. Unlike strncat, dest_size is the full size of dest, not the space left over. This function does NOT allocate memory. This always NUL terminates (unless siz == 0 or there were no NUL characters in the dest_size characters of dest to start with). Note Caveat: this is supposedly a more secure alternative to strcat() or strncat(), but for real security g_strconcat() is harder to mess up.

class Str
static
strlcat
(
string dest
,
string src
,)

Parameters

dest string

destination buffer, already containing one nul-terminated string

src string

source buffer

destSize gsize

length of dest buffer in bytes (not length of existing string inside dest)

Return Value

Type: gsize

size of attempted result, which is MIN (dest_size, strlen (original dest)) + strlen (src), so if retval >= dest_size, truncation occurred.

Meta