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

Function rt_strncpy

src/klibc/kstring.c:361–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359 */
360#ifndef RT_KLIBC_USING_USER_STRNCPY
361char *rt_strncpy(char *dst, const char *src, rt_size_t n)
362{
363#ifdef RT_KLIBC_USING_LIBC_STRNCPY
364 return strncpy(dst, src, n);
365#else
366 if (n != 0)
367 {
368 char *d = dst;
369 const char *s = src;
370
371 do
372 {
373 if ((*d++ = *s++) == 0)
374 {
375 /* NUL pad the remaining n-1 bytes */
376 while (--n != 0)
377 {
378 *d++ = 0;
379 }
380
381 break;
382 }
383 } while (--n != 0);
384 }
385
386 return (dst);
387#endif /* RT_KLIBC_USING_LIBC_STRNCPY */
388}
389#endif /* RT_KLIBC_USING_USER_STRNCPY */
390RTM_EXPORT(rt_strncpy);
391

Callers 15

finsh_set_passwordFunction · 0.85
msh_auto_completeFunction · 0.85
lwp_setcwdFunction · 0.85
lwp_loadFunction · 0.85
list_sessionFunction · 0.85
sys_gethostbyname2_rFunction · 0.85
sys_unameFunction · 0.85
list_processgroupFunction · 0.85
ctty_readlinkFunction · 0.85
rt_sfud_flash_probe_exFunction · 0.85

Calls

no outgoing calls

Tested by 15

utest_testcase_runFunction · 0.68
uart_taskFunction · 0.68
i2c_threadFunction · 0.68
i2c_taskFunction · 0.68
spi_taskFunction · 0.68
uart_taskFunction · 0.68
i2c_threadFunction · 0.68
i2c_taskFunction · 0.68
spi_taskFunction · 0.68
uart_taskFunction · 0.68
i2c_threadFunction · 0.68
i2c_taskFunction · 0.68