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.
This commit is contained in:
Lennart Poettering
2017-07-31 18:20:28 +02:00
parent 6f8cbcdb27
commit 7bf7ce28b5
8 changed files with 24 additions and 7 deletions
+2 -2
View File
@@ -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 (;;) {