MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_strdup

Function rt_strdup

src/klibc/kstring.c:544–557  ·  view source on GitHub ↗

* @brief This function will duplicate a string. * * @param s is the string to be duplicated. * * @return The string address of the copy. */

Source from the content-addressed store, hash-verified

542 * @return The string address of the copy.
543 */
544char *rt_strdup(const char *s)
545{
546 rt_size_t len = rt_strlen(s) + 1;
547 char *tmp = (char *)rt_malloc(len);
548
549 if (!tmp)
550 {
551 return RT_NULL;
552 }
553
554 rt_memcpy(tmp, s, len);
555
556 return tmp;
557}
558RTM_EXPORT(rt_strdup);
559#endif /* RT_USING_HEAP */

Callers 15

sys_getaddrinfoFunction · 0.85
sys_gethostbyname2_rFunction · 0.85
rt_ofw_bootargs_selectFunction · 0.85
dlmodule_execFunction · 0.85
dlmodule_exec_customFunction · 0.85
dfs_normalize_pathFunction · 0.85
dfs_file_openFunction · 0.85
lsFunction · 0.85
devtmpfs_symlinkFunction · 0.85
proc_findFunction · 0.85
proc_createFunction · 0.85
proc_symlinkFunction · 0.85

Calls 3

rt_strlenFunction · 0.85
rt_mallocFunction · 0.85
rt_memcpyFunction · 0.85

Tested by

no test coverage detected