Function

GLib-2.0GLibstrlcpy

  • 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.

    Parameters

    • dest: string

      destination buffer

    • src: string

      source buffer

    • dest_size: number

      length of dest in bytes

    Returns number

    length of src