mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
Replace strdup_or_null() by strdup_to()
I didn't know that this helper existed… It is very similar to strdup_to_full(), but all callers can actually be replaced by strdup_to(), which has more fitting semantics.
This commit is contained in:
@@ -303,25 +303,4 @@ bool version_is_valid_versionspec(const char *s);
|
||||
|
||||
ssize_t strlevenshtein(const char *x, const char *y);
|
||||
|
||||
static inline int strdup_or_null(const char *s, char **ret) {
|
||||
char *c;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* This is a lot like strdup(), but is happy with NULL strings, and does not treat that as error, but
|
||||
* copies the NULL value. */
|
||||
|
||||
if (!s) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
c = strdup(s);
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *strrstr(const char *haystack, const char *needle);
|
||||
|
||||
Reference in New Issue
Block a user