On Sep 2, 2009, at 8:49 AM, Peter Harris wrote: > - Re-implement strnlen for people who have only ISO C. > > Peter Harris How about using memchr? (I don't know what kind of #ifdefs to wrap this in, though.) size_t strnlen(const char *s, size_t len) { const char *end = (const char *)memchr(s, 0, len); return end ? end-s : len; } Ian