diff --git a/src/kservice.c b/src/kservice.c index 4a464b57dcfa33e72db48625e681a18cc54495a3..243d00cdfc733950a4060899ae7ceb9ed12e6e67 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -335,6 +335,26 @@ char *rt_strncpy(char *dest, const char *src, rt_ubase_t n) return dest; } +/** + * This function will copy string no more than n bytes. + * + * @param dest the string to copy + * @param src the string to be copied + * @param n the maximum copied length + * + * @return the result with '\0' at the end + */ +char *rt_strlcpy(char *dest, const char *src, rt_ubase_t n) +{ + char *tmp = (char *) dest, *s = (char *) src; + + while(n--) + *tmp++ = *s++; + *tmp = '\0'; + + return dest; +} + /** * This function will compare two strings with specified maximum length *