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

Function strncpy

payloads/libpayload/libc/string.c:132–141  ·  view source on GitHub ↗

* Copy a string with a maximum length. * * @param d The destination memory. * @param s The source string. * @param n Copy at most n characters as length of the string. * @return A pointer to the destination memory. */

Source from the content-addressed store, hash-verified

130 * @return A pointer to the destination memory.
131 */
132char *strncpy(char *d, const char *s, size_t n)
133{
134 /* Use +1 to get the NUL terminator. */
135 size_t max = n > strlen(s) + 1 ? strlen(s) + 1 : n;
136
137 for (size_t i = 0; i < max; i++)
138 d[i] = (char)s[i];
139
140 return d;
141}
142
143/**
144 * Copy a string.

Callers 9

strcpyFunction · 0.70
strdupFunction · 0.70
strndupFunction · 0.70
set_option_from_stringFunction · 0.50
mainFunction · 0.50
form_request_by_nameFunction · 0.50
menu_request_by_nameFunction · 0.50
parse_mainboardFunction · 0.50
parse_stringsFunction · 0.50

Calls 1

strlenFunction · 0.85

Tested by

no test coverage detected