[Asterisk-Dev] ast_strlen_zero or ast_empty_string() ?

Luigi Rizzo rizzo at icir.org
Wed May 4 02:34:14 MST 2005


in most cases in the sources we find

        if (!s || ast_strlen_zero(s)) {
                ...
        }

or the equivalent negated form.

I believe it would be strongly advisable to replace ast_strlen_zero() with

        int ast_empty_string(const char *s)
        {
                return s == NULL || *s == '\0';
        }

(it is in include/asterisk/utils.h) to simplify the code and possibly
also trap cases where the NULL check is forgotten.
Having the function inline (not that I particularly like it, but
this is the way it is now) will still enable the compiler to
do all required optimizations.

        cheers
        luigi



More information about the asterisk-dev mailing list