summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-06 14:08:17 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-06 14:15:59 -0700
commit0c836ebc47cab2f37274ae03ab2be6c7b2fd0456 (patch)
tree2c55ca0c5aa1bb6e9dcb6cc8bb920cb28c75b5cd /dive.h
parent024420a60ddf7d18a6bd2ce4aad30344be0edbac (diff)
downloadsubsurface-0c836ebc47cab2f37274ae03ab2be6c7b2fd0456.tar.gz
Simplify string comparison
This is based on Linus' idea on the mailing list. Treat NULL strings and empty strings as identical. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index 5215c4997..13606f39e 100644
--- a/dive.h
+++ b/dive.h
@@ -7,6 +7,7 @@
#include <math.h>
#include <zip.h>
#include <sqlite3.h>
+#include <string.h>
/* Windows has no MIN/MAX macros - so let's just roll our own */
#define MIN(x, y) ({ \
@@ -23,6 +24,11 @@
#define IS_FP_SAME(_a, _b) (fabs((_a) - (_b)) < 0.000001 * MAX(fabs(_a), fabs(_b)))
+static inline int same_string(const char *a, const char *b)
+{
+ return !strcmp(a ? : "", b ? : "");
+}
+
#include <libxml/tree.h>
#include <libxslt/transform.h>