summaryrefslogtreecommitdiff
path: root/lib/string/strlcat.c
blob: a61821de7afaa654e2b0c6c01083a6c3856a77be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/* SPDX-License-Identifier: MIT */
/* Derived from musl libc (Copyright © 2005-2020 Rich Felker, et al.) */

#define _BSD_SOURCE
#include <string.h>

size_t strlcat(char *d, const char *s, size_t n)
{
	size_t l = strnlen(d, n);
	if (l == n) return l + strlen(s);
	return l + strlcpy(d+l, s, n-l);
}