mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
56501dda1e
commit
2cfe97e4dd
2 changed files with 17 additions and 14 deletions
5
dive.h
5
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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue