From 5e8f578e7838920ecdf7095e0c2026ab1542afb4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 16 May 2017 11:56:56 +0200 Subject: [PATCH] util/ConcatString: return the end pointer --- src/util/Alloc.cxx | 3 +-- src/util/ConcatString.hxx | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/util/Alloc.cxx b/src/util/Alloc.cxx index 115dc96bb..e6f0f25ea 100644 --- a/src/util/Alloc.cxx +++ b/src/util/Alloc.cxx @@ -88,8 +88,7 @@ t_xstrcatdup(Args&&... args) const size_t total = FillLengths(lengths, args...); char *p = (char *)xalloc(total + 1); - StringCat(p, lengths, args...); - p[total] = 0; + *StringCat(p, lengths, args...) = 0; return p; } diff --git a/src/util/ConcatString.hxx b/src/util/ConcatString.hxx index e3a6a0ad0..abc6dd59b 100644 --- a/src/util/ConcatString.hxx +++ b/src/util/ConcatString.hxx @@ -49,18 +49,18 @@ FillLengths(size_t *lengths, const char *a) } template -void +char * StringCat(char *p, const size_t *lengths, const char *a, Args&&... args) { - StringCat(p, lengths, a); - StringCat(p + *lengths, lengths + 1, args...); + return StringCat(StringCat(p, lengths, a), + lengths + 1, args...); } template<> -void +char * StringCat(char *p, const size_t *lengths, const char *a) { - std::copy_n(a, *lengths, p); + return std::copy_n(a, *lengths, p); } #endif