diff options
| author | Meco Man <[email protected]> | 2021-12-20 13:33:44 -0500 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2021-12-22 13:04:45 +0800 |
| commit | 457348e21a6e0e4d6355d994a69285ba47496c20 (patch) | |
| tree | 14a6711e364d3832aaf22e3463865a000026f5b3 /src | |
| parent | acc62c1e3da639ec22ab0d6b44e4f777b6225603 (diff) | |
[kservice] implement rt_strcpy()
Diffstat (limited to 'src')
| -rw-r--r-- | src/kservice.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/kservice.c b/src/kservice.c index a441124816..fa0da4c7c4 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -18,6 +18,7 @@ * 2013-09-24 aozima make sure the device is in STREAM mode when used by rt_kprintf. * 2015-07-06 Bernard Add rt_assert_handler routine. * 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB + * 2021-12-20 Meco Man implement rt_strcpy() */ #include <rtthread.h> @@ -300,7 +301,7 @@ RTM_EXPORT(rt_memcpy); * * @return The address of destination memory. */ -void *rt_memmove(void *dest, const void *src, rt_ubase_t n) +void *rt_memmove(void *dest, const void *src, rt_size_t n) { char *tmp = (char *)dest, *s = (char *)src; @@ -336,7 +337,7 @@ RTM_EXPORT(rt_memmove); * If the result > 0, cs is greater than ct. * If the result = 0, cs is equal to ct. */ -rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count) +rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_size_t count) { const unsigned char *su1, *su2; int res = 0; @@ -421,7 +422,7 @@ RTM_EXPORT(rt_strcasecmp); * * @return The address where the copied content is stored. */ -char *rt_strncpy(char *dst, const char *src, rt_ubase_t n) +char *rt_strncpy(char *dst, const char *src, rt_size_t n) { if (n != 0) { @@ -445,6 +446,21 @@ char *rt_strncpy(char *dst, const char *src, rt_ubase_t n) RTM_EXPORT(rt_strncpy); /** + * This function will copy string. + * + * @param dst points to the address used to store the copied content. + * + * @param src is the string to be copied. + * + * @return The address where the copied content is stored. + */ +char *rt_strcpy(char *dst, const char *src) +{ + return rt_strncpy(dst, src, (rt_size_t)-1); +} +RTM_EXPORT(rt_strcpy); + +/** * This function will compare two strings with specified maximum length. * * @param cs is the string to be compared. @@ -458,7 +474,7 @@ RTM_EXPORT(rt_strncpy); * If the result > 0, cs is greater than ct. * If the result = 0, cs is equal to ct. */ -rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count) +rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_size_t count) { register signed char __res = 0; |
