diff options
| author | zhangjun <[email protected]> | 2016-08-12 22:14:07 +0800 |
|---|---|---|
| committer | zhangjun <[email protected]> | 2016-08-12 22:14:07 +0800 |
| commit | 65ac4a081070dd51553b1aea3cfb784ac0290d47 (patch) | |
| tree | 1c102820ebf41f1dbaf2fe5f1375ff9bc5eb04cb /src/kservice.c | |
| parent | 891050cb3d84f0592f8fc4c4345a86613fc12673 (diff) | |
增加rt_strnlen,lua采用单独的线程
Diffstat (limited to 'src/kservice.c')
| -rw-r--r-- | src/kservice.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/kservice.c b/src/kservice.c index 7250639346..f5cd934e2d 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -462,7 +462,26 @@ rt_int32_t rt_strcmp(const char *cs, const char *ct) return (*cs - *ct); } RTM_EXPORT(rt_strcmp); +/** + * The strnlen() function returns the number of characters in the + * string pointed to by s, excluding the terminating null byte ('\0'), + * but at most maxlen. In doing this, strnlen() looks only at the + * first maxlen characters in the string pointed to by s and never + * beyond s+maxlen. + * + * @param s the string + * @param maxlen the max size + * @return the length of string + */ +rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen) +{ + const char *sc; + + for (sc = s; *sc != '\0' && sc - s < maxlen; ++sc) /* nothing */ + ; + return sc - s; +} /** * This function will return the length of a string, which terminate will * null character. |
