diff options
| author | 2014-07-02 21:05:22 -0700 | |
|---|---|---|
| committer | 2014-07-03 09:37:55 -0700 | |
| commit | 2cfe97e4dd5093b13301ed98a97b6edd41da56c7 (patch) | |
| tree | 16cf771fa29bab08a933be448f4b6f9f6f9a3659 /dive.h | |
| parent | 56501dda1e56f32be98bf4dc475411c56dd223da (diff) | |
| download | subsurface-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.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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> |