diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-30 08:35:04 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-08-30 08:37:32 +0200 |
| commit | 0966efb179385b604f1404eed36311f3c4b6e545 (patch) | |
| tree | f52b9200c5947e466442d7989f90b3f07366436e /dev/lib/utility | |
| parent | e337f736afd613de6742c942d65e3124101ead8a (diff) | |
fix: memory leak fixed in `basic_chunk_string`
fix: `tracked_ptr` example for `make_tracked`
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/lib/utility')
| -rw-r--r-- | dev/lib/utility/chunk_string.hpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/dev/lib/utility/chunk_string.hpp b/dev/lib/utility/chunk_string.hpp index 2dffccd..958d7a8 100644 --- a/dev/lib/utility/chunk_string.hpp +++ b/dev/lib/utility/chunk_string.hpp @@ -27,7 +27,7 @@ namespace ocl bool bad_{false}; public: - const bool& bad{bad_}; + const bool& bad{bad_}; basic_chunk_string() = default; @@ -41,11 +41,17 @@ namespace ocl this->operator+=(in); } - ~basic_chunk_string() = default; + ~basic_chunk_string() + { + if (extended_chunks_) + delete[] extended_chunks_; + extended_chunks_ = nullptr; + } - basic_chunk_string& operator=(const basic_chunk_string&) = default; - basic_chunk_string(const basic_chunk_string&) = default; + basic_chunk_string& operator=(const basic_chunk_string&) = delete; + basic_chunk_string(const basic_chunk_string&) = delete; + public: basic_chunk_string& operator+=(const std::basic_string<char_type>& in) { if (in.empty() || bad_) @@ -53,7 +59,7 @@ namespace ocl if (chunk_total_ > max_chunk_size) { - bad_ = true; + bad_ = true; return *this; } @@ -69,9 +75,14 @@ namespace ocl return *this; } - const std::basic_string<char_type>& str() const noexcept + std::basic_string<char_type> str() const noexcept { - return packed_chunks_; + std::basic_string<char_type> ret; + + ret += packed_chunks_; + ret += extended_chunks_; + + return ret; } void print() noexcept |
