Function

GLib-2.0GLibstrlcat

  • 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. It always nul-terminates (unless dest_size == 0 or there were no nul characters in the dest_size characters of dest to start with).

    Caveat: this is supposedly a more secure alternative to strcat() or strncat(), but for real security GLib.strconcat is harder to mess up.

    Parameters

    • dest: string

      destination buffer, already containing one nul-terminated string

    • src: string

      source buffer

    • dest_size: number

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

    Returns number

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