summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-03-19 21:08:52 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2024-03-20 15:18:21 +0100
commit6a705f1234919c255cc230403ad6749edabf83be (patch)
tree325220dfa5cf279a7ce9af3babf04631d90fc2d2 /src/basic
parentbasic/string-util: use strdup_to() in string_extract_line() (diff)
downloadsystemd-6a705f1234919c255cc230403ad6749edabf83be.tar.xz
systemd-6a705f1234919c255cc230403ad6749edabf83be.zip
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.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/string-util.h21
1 files changed, 0 insertions, 21 deletions
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index c402cd3af0..a68f3c94ab 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -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);