X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrlen.c;h=ec0c21e7134a8c96edbac8b28d353c2592b1abdf;hp=9dfc38fed0a058172142e2441820e6b2aaffa1c0;hb=19b4cc9a30c2ede7a0cd6c417b5f26851376b708;hpb=419762f3c5da2a601e3c7427e25ae01293a73223 diff --git a/functions/string/strlen.c b/functions/string/strlen.c index 9dfc38f..ec0c21e 100644 --- a/functions/string/strlen.c +++ b/functions/string/strlen.c @@ -5,25 +5,14 @@ // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -size_t strlen( const char * s ) { /* TODO */ }; +#include <__size_t.h> -/* Therx code +size_t strlen( const char * src ) { - const char * start = s1; - while (*s1) + size_t len = 0; + while ( src[len] != '\0' ) { - s1++; + ++len; } - return s1 - start; + return len; } -*/ - -/* PDPC code - unreviewed -{ - const char *p; - - p = s; - while (*p != '\0') p++; - return ((size_t)(p - s)); -} -*/