From de5eb70032344c02d3dfe09ff9d830c16bd595f0 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 22 May 2013 14:08:19 +0200 Subject: [PATCH] core-util: Add pa_safe_streq Like pa_streq, but does not blow up on NULL pointers. Signed-off-by: David Henningsson --- src/pulsecore/core-util.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index 15e68092b..7b59fbcd4 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -208,6 +208,15 @@ void pa_unset_env_recorded(void); pa_bool_t pa_in_system_mode(void); #define pa_streq(a,b) (!strcmp((a),(b))) + +/* Like pa_streq, but does not blow up on NULL pointers. */ +static inline bool pa_safe_streq(const char *a, const char *b) +{ + if (a == NULL || b == NULL) + return a == b; + return pa_streq(a, b); +} + pa_bool_t pa_str_in_list_spaces(const char *needle, const char *haystack); char *pa_get_host_name_malloc(void);