[vlc-devel] [DISCUSSION] To use or not to use EMPTY_STR?
Rémi Denis-Courmont
remi at remlab.net
Fri Aug 5 14:53:16 CEST 2016
Le 2016-08-05 14:20, Filip Roséen a écrit :
> Hi guys and gals,
>
> #define EMPTY_STR(str) (!str || !*str)
>
> The above macro is defined in include/vlc_common.h, and it is used in
> several places throughout the codebase; though we have both old and
> new code that does not make use of the macro (in places where it
> could).
In many (but not all) sites, it is cargo cult. Either the string
pointer cannot NULL, or the string cannot be empty.
>
> * What is our current position of such helper-macros?
I am not aware of a project-wide position.
The macro lacks expansion safety, in several ways. And its name is
confusingly wrong: A NULL string pointer is not a string, and thus not
an empty string. The distinction sometimes does matter.
Therefore, I dislike it and avoid it.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list