[Asterisk-Dev] ast_strlen_zero or ast_empty_string() ?

Steve Kann stevek at stevek.com
Wed May 4 08:54:53 MST 2005


Kevin P. Fleming wrote:

> Andrew Kohlsmith wrote:
>
>> Why not
>>
>> #define ast_empty_string(x) ( x==NULL || *s == '\0' )
>>
>> ??  Why incur the call overhead or piss around with declaring it inline?
>
>
> Well, one reason is that if the argument to the macro has side 
> effects, they will happen twice. For example:
>
>   if (ast_empty_string(array[x++]))
>
> Granted, this is an unusual case, but it's still legitimate. 'static 
> inline' declared in a header file is essentially the same as a macro 
> as far as code generation/optimization, unless optimization is turned 
> completely off.


That, and that macro will only work if your string is called "s" :)

-SteveK




More information about the asterisk-dev mailing list