X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrlen.c;h=ec0c21e7134a8c96edbac8b28d353c2592b1abdf;hb=96c55f60f49ceb842cf30e0018bb963ef9ed7d1c;hp=9dfc38fed0a058172142e2441820e6b2aaffa1c0;hpb=d1472915f1f94028ccbf407e7c4f858c1e1c0b20;p=pdclib.old 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)); -} -*/