bug in the 'ro' text formatter

Jonathan I. Kamens jik at athena.mit.edu
Tue Feb 27 07:05:17 AEST 1990


In article <1126 at laas.laas.fr>, rlacoste at kebra.laas.fr (Robert Lacoste) writes:
> 	Proposed correction:
> 		Replacement of all strlen calls by mystrlen, with the
> 		following definition:
> 
> 			int mystrlen(s)
> 			char *s;
> 			{
> 			  if (s==NULL) return (0);
> 			  else return(strlen(s));
> 			}

  I sure hope your compiler has inline functions and automatically knows
when to use them best; otherwise, you're introducing an awful lot of
overhead which is going to slow down the program quite a bit if there
are a lot of calls to strlen.

  Instead of what you've proposed, I suggest this alternative:

    #define mystrlen(s) ((s) ? strlen(s) : 0)

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.sources.bugs mailing list