summaryrefslogblamecommitdiff
path: root/portability/strlcpy.c
blob: 6ce46e3d3e970d63c76569c282c0f17414a3dac0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                       
#include <stddef.h>
#include <string.h>

size_t strlcpy(char *dst, const char *src, size_t size)
{
	size_t ret = strlen(src), len;
	if (!size) return ret;
	len = ret;
	if (len >= size) len = size - 1;
	memcpy(dst, src, len);
	dst[len] = 0;
	return ret;
}