ref: ddf32b64ea557c2f9f3adec475288cbffc9b12fc
parent: dc1778213cfa24ecb191208c653fd4204efcf3e7
author: Quentin Rameau <[email protected]>
date: Thu Feb 16 20:16:53 EST 2017
[libc] Use a counter in strlen
--- a/libc/src/strlen.c
+++ b/libc/src/strlen.c
@@ -5,9 +5,9 @@
size_t
strlen(const char *s)
{
- const char *t;
+ size_t n = 0;
- for (t = s; *t; ++t)
- /* nothing */;
- return t - s;
+ while (*s++)
+ ++n;
+ return n;
}