GLib.strlcpy
Description: Reference for GLib.strlcpy

### Function

# GLibstrlcpy

#### Declaration [src]

    gsize
    g_strlcpy (
      gchar* dest,
      const gchar* src,
      gsize dest_size
    )

#### Description [src]

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.

#### Parameters

`dest`

  Type: `gchar*`

  Destination buffer.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`src`

  Type: `const gchar*`

  Source buffer.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`dest_size`

  Type: `gsize`

  Length of `dest` in bytes.

#### Return value

Type: `gsize`

Length of `src`.