[Asterisk-Dev] ast_strlen_zero or ast_empty_string() ?

Kevin P. Fleming kpfleming at digium.com
Wed May 4 08:00:39 MST 2005


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.



More information about the asterisk-dev mailing list