Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.sources.bugs Subject: Re: bug in the 'ro' text formatter Message-ID: <1990Feb26.200517.20499@athena.mit.edu> Date: 26 Feb 90 20:05:17 GMT References: <1126@laas.laas.fr> Sender: news@athena.mit.edu (News system) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 25 In article <1126@laas.laas.fr>, rlacoste@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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710