diff options
author | Max Kellermann <max@duempel.org> | 2015-09-01 21:11:22 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-09-01 21:11:22 +0200 |
commit | ffe689363f1350e86255ee8c03585a2a744a8819 (patch) | |
tree | 1f036b95b88c500cbddbfec8e5d7237dba515a07 | |
parent | 48d7fedbc085bcefd4db1e41f14a5390b7e032c0 (diff) | |
download | mpd-ffe689363f1350e86255ee8c03585a2a744a8819.tar.gz mpd-ffe689363f1350e86255ee8c03585a2a744a8819.tar.xz mpd-ffe689363f1350e86255ee8c03585a2a744a8819.zip |
util/AllocatedString: add constant "SENTINEL"
Diffstat (limited to '')
-rw-r--r-- | src/util/AllocatedString.hxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/util/AllocatedString.hxx b/src/util/AllocatedString.hxx index c1d844426..e01955381 100644 --- a/src/util/AllocatedString.hxx +++ b/src/util/AllocatedString.hxx @@ -47,6 +47,8 @@ public: typedef typename StringPointer<T>::pointer pointer; typedef typename StringPointer<T>::const_pointer const_pointer; + static constexpr value_type SENTINEL = '\0'; + private: pointer value; @@ -73,7 +75,7 @@ public: static AllocatedString Empty() { auto p = new value_type[1]; - p[0] = value_type(0); + p[0] = SENTINEL; return Donate(p); } @@ -82,14 +84,14 @@ public: static AllocatedString Duplicate(const_pointer begin, const_pointer end) { auto p = new value_type[end - begin + 1]; - *std::copy(begin, end, p) = 0; + *std::copy(begin, end, p) = SENTINEL; return Donate(p); } static AllocatedString Duplicate(const_pointer begin, size_t length) { auto p = new value_type[length]; - *std::copy_n(begin, length, p) = 0; + *std::copy_n(begin, length, p) = SENTINEL; return Donate(p); } @@ -107,7 +109,7 @@ public: } bool empty() const { - return *value == 0; + return *value == SENTINEL; } pointer Steal() { |