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

Function strndup

components/libc/compilers/common/cstring.c:174–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174char *strndup(const char *s, size_t size)
175{
176 size_t nsize = strnlen(s, size);
177 char *news = (char *)malloc(nsize + 1);
178 if (news)
179 {
180 rt_memcpy(news, s, nsize);
181 news[nsize] = '\0';
182 }
183
184 return news;
185}
186
187rt_weak char *strtok_r(char *str, const char *delim, char **saveptr)
188{

Callers 2

lwp_struct_copyFunction · 0.85
sys_execveFunction · 0.85

Calls 3

strnlenFunction · 0.85
rt_memcpyFunction · 0.85
mallocFunction · 0.50

Tested by

no test coverage detected