[asterisk-dev] any difference between NULL and "" in struct ast_callerid fields ?

Luigi Rizzo rizzo at icir.org
Tue Apr 18 09:50:59 MST 2006


hi,
browsing throughout the code, i see that some places map
a NULL value in the struct ast_callerid fields to "<unknown>"
or similar string, but the empty string is left alone.

However, i am not so sure that the behaviour is
consistent across the whole code, and especially,
i cannot see a reason why the empty string "" should
be treated differently from NULL.

In many other places in asterisk, NULL and "" are considered the
same thing and we have plenty of utility functions code that assume
that.

The reason is for this behaviour is an important one:

    we have both dynamically and statically allocated strings, and the
    latter cannot store NULL and must represent it as an empty string.

So, even if parts of the code that handle the CID fields
make use of the difference between NULL and "", there is a
huge risk that this difference is lost when passing values
around between different types of buffers.

As a consequence, unless there are convincing explaination
on why we need to differentiate that, I am going to add
comments, in include/asterisk/channel.h, that in the ast_callerid
fields, NULL and "" are considered equivalent, and then start
making the code consistent with the above spec.

comments welcome.

	cheers
	luigi



More information about the asterisk-dev mailing list