summaryrefslogtreecommitdiff
path: root/oslib/strlcat.c
blob: 6c4c67863256891f15b40b47b1969db1ab8ee37e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef CONFIG_STRLCAT

#include <string.h>
#include "strlcat.h"

size_t strlcat(char *dst, const char *src, size_t size)
{
	size_t dstlen;
	size_t srclen;

	dstlen = strlen(dst);
	size -= dstlen + 1;

	/* return if no room */
	if (!size)
		return dstlen;

	srclen = strlen(src);
	if (srclen > size)
		srclen = size;

	memcpy(dst + dstlen, src, srclen);
	dst[dstlen + srclen] = '\0';

	return dstlen + srclen;
}

#endif