[Asterisk-Dev] FW: asterisk/doc CODING-GUIDELINES,1.4,1.5

Jerris, Michael MI mjerris at ofllc.com
Wed Jan 19 05:45:22 MST 2005


It would probably be more efficient to check just the first char of the
string to see if it is 0 than to loop through the whole string to see if
it is > 0 length.

-----Original Message-----
From: asterisk-dev-bounces at lists.digium.com
[mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Andrew
Kohlsmith
Sent: Wednesday, January 19, 2005 7:35 AM
To: asterisk-dev at lists.digium.com
Subject: Re: [Asterisk-Dev] FW: asterisk/doc CODING-GUIDELINES,1.4,1.5

On January 19, 2005 12:00 am, Edwin Groothuis wrote:
> Any C programmer who checks with strlen() if the length of a string is

> greater than zero should be forced to read the K&R book again to 
> understand how the C programming language actually works.

Save me a trip to the library and tell me when strlen() would not return
the length of a string?

I've been a C programmer for over a decade now and can't think of a
reason why this would be considered a bad thing.  At the very heart of
strlen would be a loop something along the line of

int count = 0;
while (*(string++))
        count++;

Yes my C's getting rusty but can you think of a better/faster way to
count the characters in a zero-terminated string?

-A.
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev




More information about the asterisk-dev mailing list