From e05797fba258d7a58987cc8870fae6e34b94fe46 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 10 Apr 2010 04:38:14 +0200 Subject: util: introduce streq_ptr() for comparing strings or their pointers --- util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index b4d6eefbd2..3fe59c8ebb 100644 --- a/util.c +++ b/util.c @@ -42,6 +42,19 @@ #include "log.h" #include "strv.h" +bool streq_ptr(const char *a, const char *b) { + + /* Like streq(), but tries to make sense of NULL pointers */ + + if (a && b) + return streq(a, b); + + if (!a && !b) + return true; + + return false; +} + usec_t now(clockid_t clock_id) { struct timespec ts; -- cgit v1.2.3-54-g00ecf