diff options
author | Thomas White <taw@physics.org> | 2020-02-21 17:00:59 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:39:50 +0200 |
commit | 12fa6375acb536e61f41c006fc783e5e8f0c7a92 (patch) | |
tree | 3c81bb26b7ce42ac2e9b113376d106ac0b84c331 | |
parent | 7724da7f1ac050838ffce551c9dad52083daf873 (diff) |
Add safe_strdup() to utils
-rw-r--r-- | libcrystfel/src/utils.c | 7 | ||||
-rw-r--r-- | libcrystfel/src/utils.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c index de1dc2f4..0c01c069 100644 --- a/libcrystfel/src/utils.c +++ b/libcrystfel/src/utils.c @@ -503,6 +503,13 @@ char *check_prefix(char *prefix) } +char *safe_strdup(const char *in) +{ + if ( in == NULL ) return NULL; + return strdup(in); +} + + char *safe_basename(const char *in) { int i; diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index b2694f2a..f406ef6c 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -222,6 +222,7 @@ extern pthread_mutex_t stderr_lock; extern char *check_prefix(char *prefix); extern char *safe_basename(const char *in); +extern char *safe_strdup(const char *in); extern void strip_extension(char *bfn); extern char *load_entire_file(const char *filename); |