MCPcopy Create free account
hub / github.com/coreboot/coreboot / strlcat

Function strlcat

payloads/libpayload/libc/string.c:163–179  ·  view source on GitHub ↗

* Concatenates two strings with a maximum length. * * @param d The destination string. * @param s The source string. * @param n d will have at most n-1 characters (plus NUL) after invocation. * @return The total length of the concatenated string. */

Source from the content-addressed store, hash-verified

161 * @return The total length of the concatenated string.
162 */
163size_t strlcat(char *d, const char *s, size_t n)
164{
165 size_t sl = strlen(s);
166 size_t dl = strlen(d);
167
168 if (n <= dl + 1)
169 return sl + dl;
170
171 char *p = d + dl;
172 size_t max = n > (sl + dl) ? sl : (n - dl - 1);
173
174 for (size_t i = 0; i < max; i++)
175 p[i] = s[i];
176
177 p[max] = '\0';
178 return sl + dl;
179}
180
181/**
182 * Find a character in a string.

Callers

nothing calls this directly

Calls 1

strlenFunction · 0.85

Tested by

no test coverage detected