new function
| From: | (Marcus Boerger) | Date: | Sat, 02 Mar 2002 16:12:07 +0000 |
| Subject: | new function | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9590@lists.php.net to get a copy of this message | ||
hi guys,
what about a new function called strnlen str*n*len which will
return the length of a string with a given maximum to avoid
problems with strings not zero terminated.
size_t strnlen( char* str, size_t maxlen) {
size_t len = 0;
if ( str && maxlen && (*str)) {
do {
len++;
} while ( (--maxlen) && *(++str));
}
return len;
}
i suggest we put this in a single c file near strlcpy
marcus
--------->>> mailto:marcus.boerger@post.rwth-aachen.de <<<------------
I don't want to start any blashphemous rumours
but i think that god's got a sick sense of humor
and when i die i expect to find him laughing.
Depeche Mode
--------------->>> http://www.marcus-boerger.de <<<-------------------