Need strnlen().

Stephen J. Muir stephen at dcl-cs.UUCP
Fri Nov 8 08:14:07 AEST 1985


I think that there should be a function called "strnlen" as follows:

int strnlen (string, size)
	char	*string;
	int	size;

where "size" is the maximum number of bytes in "string".

The reason is that, if a character array is passed as argument, and it is not
terminated with a null byte, then "strlen" will keep going, possibly hitting an
unallocated piece of memory.
-- 
UUCP:	...!seismo!mcvax!ukc!dcl-cs!stephen
DARPA:	stephen%comp.lancs.ac.uk at ucl-cs	| Post: University of Lancaster,
JANET:	stephen at uk.ac.lancs.comp	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4599		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR



More information about the Comp.lang.c mailing list