diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/utils/CharReader.cpp | 11 | ||||
-rw-r--r-- | src/core/utils/CharReader.hpp | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/core/utils/CharReader.cpp b/src/core/utils/CharReader.cpp index c661b6f..61616d7 100644 --- a/src/core/utils/CharReader.cpp +++ b/src/core/utils/CharReader.cpp @@ -17,6 +17,7 @@ */ #include <algorithm> +#include <cassert> #include <limits> #include <sstream> @@ -80,6 +81,16 @@ Buffer::Buffer(const std::string &str) startBucket = buckets.begin(); } +#ifndef NDEBUG +Buffer::~Buffer() +{ + // Make sure all cursors have been deleted + for (bool cursor_alive: alive) { + assert(!cursor_alive); + } +} +#endif + void Buffer::advance(BucketIterator &it) { it++; diff --git a/src/core/utils/CharReader.hpp b/src/core/utils/CharReader.hpp index 86f09db..1306026 100644 --- a/src/core/utils/CharReader.hpp +++ b/src/core/utils/CharReader.hpp @@ -242,6 +242,14 @@ public: */ Buffer(const std::string &str); +#ifndef NDEBUG + /** + * Destructor of the Buffer class. Makes sure that all cursors have been + * freed. + */ + ~Buffer(); +#endif + // No copy Buffer(const Buffer &) = delete; |