summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-02 21:05:22 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-03 09:37:55 -0700
commit2cfe97e4dd5093b13301ed98a97b6edd41da56c7 (patch)
tree16cf771fa29bab08a933be448f4b6f9f6f9a3659 /dive.h
parent56501dda1e56f32be98bf4dc475411c56dd223da (diff)
downloadsubsurface-2cfe97e4dd5093b13301ed98a97b6edd41da56c7.tar.gz
Add a "smart strdup" helper named copy_string()
If the string is non-NULL, copy it, otherwise return NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index a13c4fd3b..8549296d7 100644
--- a/dive.h
+++ b/dive.h
@@ -29,6 +29,11 @@ static inline int same_string(const char *a, const char *b)
return !strcmp(a ?: "", b ?: "");
}
+static inline char *copy_string(const char *s)
+{
+ return s ? strdup(s) : NULL;
+}
+
#include <libxml/tree.h>
#include <libxslt/transform.h>