- size_t dest_length = strnlen (dest, size);
- if (dest_length != size)
- {
- /* Copy at most the remaining number of characters in the
- destination buffer. Leave for the NUL terminator. */
- size_t to_copy = size - dest_length - 1;
- /* But not more than what is available in the source string. */
- if (to_copy > src_length)
- to_copy = src_length;
+ size_t dest_length = strnlen(dest, destsize);
+ if (dest_length != destsize) {
+ /* Copy at most the remaining number of characters in the
+ destination buffer. Leave for the NUL terminator. */
+ size_t to_copy = destsize - dest_length - 1;
+ /* But not more than what is available in the source string. */
+ if (to_copy > src_length)
+ to_copy = src_length;