summaryrefslogtreecommitdiffstats
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-07-20 11:38:15 +0200
committerLennart Poettering <lennart@poettering.net>2017-07-31 18:20:28 +0200
commit7bf7ce28b5a1f589f0f2382e54c03ab9b0794fab (patch)
tree701387d210e1e75c063a734ea6fe13bf33d88f87 /src/basic/string-util.c
parentprocess-util: slightly optimize querying of our own process metadata (diff)
downloadsystemd-7bf7ce28b5a1f589f0f2382e54c03ab9b0794fab.tar.xz
systemd-7bf7ce28b5a1f589f0f2382e54c03ab9b0794fab.zip
string-util: add strlen_ptr() helper
strlen_ptr() is to strlen() what streq_ptr() is to streq(): i.e. it handles NULL strings in a smart way.
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index cd58ef97ef..3287865863 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -215,7 +215,7 @@ char *strnappend(const char *s, const char *suffix, size_t b) {
}
char *strappend(const char *s, const char *suffix) {
- return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
+ return strnappend(s, suffix, strlen_ptr(suffix));
}
char *strjoin_real(const char *x, ...) {
@@ -707,7 +707,7 @@ char *strextend(char **x, ...) {
assert(x);
- l = f = *x ? strlen(*x) : 0;
+ l = f = strlen_ptr(*x);
va_start(ap, x);
for (;;) {