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:
@@ -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 (;;) {
|
||||
|
||||
Reference in New Issue
Block a user