core-util: add pa_strneq macro

This macro compares if the given two strings, with the maximum length
of n, are equal. Useful for strings that are not NULL-terminated.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
This commit is contained in:
Hajime Fujita 2016-11-06 12:53:55 -06:00 committed by Tanu Kaskinen
parent 6e6f497219
commit e2be9fca9c

View file

@ -219,6 +219,7 @@ void pa_unset_env_recorded(void);
bool pa_in_system_mode(void); bool pa_in_system_mode(void);
#define pa_streq(a,b) (!strcmp((a),(b))) #define pa_streq(a,b) (!strcmp((a),(b)))
#define pa_strneq(a,b,n) (!strncmp((a),(b),(n)))
/* Like pa_streq, but does not blow up on NULL pointers. */ /* Like pa_streq, but does not blow up on NULL pointers. */
static inline bool pa_safe_streq(const char *a, const char *b) { static inline bool pa_safe_streq(const char *a, const char *b) {