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

Function strdup

payloads/libpayload/libc/string.c:228–238  ·  view source on GitHub ↗

* Duplicate a string. * * @param s The string to duplicate. * @return A pointer to the copy of the original string. */

Source from the content-addressed store, hash-verified

226 * @return A pointer to the copy of the original string.
227 */
228char *strdup(const char *s)
229{
230 size_t n = strlen(s);
231 char *p = malloc(n + 1);
232
233 if (p != NULL) {
234 strncpy(p, s, n);
235 p[n] = 0;
236 }
237 return p;
238}
239
240/**
241 * Duplicate a string with a max length of size

Callers 5

get_option_as_stringFunction · 0.50
Generic_Enum_TypeFunction · 0.50
Copy_Enum_TypeFunction · 0.50
set_menu_markFunction · 0.50
cbfs_module_initFunction · 0.50

Calls 3

strlenFunction · 0.85
mallocFunction · 0.70
strncpyFunction · 0.70

Tested by

no test coverage detected