Need strnlen().

John Mashey mash at mips.UUCP
Tue Nov 19 17:03:22 AEST 1985


> One should never allow a character array to not have a null terminating byte.
> Doing things like this should be automatic. 
Yes, except that for (at the time, and perhaps still) good reasons,
certain structures had strings that might not be null-terminated.
Such include directories (except in 4.2), accounting file command names, 
utmp/wtmp.  Those things are why the strn* routines were written in
the first place.

I generally agree with the first advice, but there are at least a few
occasions where one extra byte is fairly handy.
-- 
-john mashey
UUCP: 	{decvax,ucbvax,ihnp4}!decwrl!mips!mash
DDD:  	415-960-1200
USPS: 	MIPS Computer Systems, 1330 Charleston Rd, Mtn View, CA 94043



More information about the Comp.lang.c mailing list