diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 425a732344..7977ee46c5 100644 --- a/src/util.c +++ b/src/util.c @@ -5682,3 +5682,21 @@ bool kexec_loaded(void) { } return loaded; } + +int strdup_or_null(const char *a, char **b) { + char *c; + + assert(b); + + if (!a) { + *b = NULL; + return 0; + } + + c = strdup(a); + if (!c) + return -ENOMEM; + + *b = c; + return 0; +} |