commit | 55baca643172849ea661f4d39a3131e78c063313 | [log] [tgz] |
---|---|---|
author | Andrew Scull <ascull@google.com> | Fri Apr 05 14:56:20 2019 +0100 |
committer | Andrew Scull <ascull@google.com> | Fri Apr 05 17:59:52 2019 +0000 |
tree | 7cda8eb2666ed44551940536b8402f49cfec3a34 | |
parent | 8fbd7ee6b2b579ce829e16598febb5559734ca90 [diff] [blame] |
Move from strlen to strnlen_s. Change-Id: I1d25a65e020b45b556723de14ef55a6140229dbb
diff --git a/src/std.c b/src/std.c index fd52a0f..9f829e8 100644 --- a/src/std.c +++ b/src/std.c
@@ -100,3 +100,18 @@ fail: panic("memmove_s failure"); } + +size_t strnlen_s(const char *str, size_t strsz) +{ + const char *p = str; + + if (str == NULL) { + return 0; + } + + while (*p && strsz--) { + p++; + } + + return p - str; +}