diff --git a/internal/tlcodegen/helpers_cpp_generated.go b/internal/tlcodegen/helpers_cpp_generated.go index 4f9dbde36..0346db9aa 100644 --- a/internal/tlcodegen/helpers_cpp_generated.go +++ b/internal/tlcodegen/helpers_cpp_generated.go @@ -173,6 +173,7 @@ namespace basictl { tl_istream::tl_istream(tl_throwable_istream &from) : provider(nullptr) { from.pass_data(*this); + this->sync_in_destructor = false; } bool tl_istream::string_read(std::string &value) noexcept { @@ -362,6 +363,7 @@ namespace basictl { tl_ostream::tl_ostream(tl_throwable_ostream &from) : provider(nullptr) { from.pass_data(*this); + this->sync_in_destructor = false; } bool tl_ostream::string_write(const std::string &value) { @@ -544,7 +546,7 @@ namespace basictl { tl_istream &operator=(tl_istream &&) = delete; - ~tl_istream() { sync(); }; + ~tl_istream() { if (sync_in_destructor) sync(); }; friend class tl_throwable_istream; @@ -652,6 +654,8 @@ namespace basictl { const std::byte *ptr{}; const std::byte *end_block{}; + bool sync_in_destructor = true; + void grow_buffer() noexcept; bool ensure_byte() noexcept; @@ -681,7 +685,7 @@ namespace basictl { tl_ostream &operator=(tl_ostream &&) = delete; - ~tl_ostream() { sync(); }; + ~tl_ostream() { if (this->sync_in_destructor) sync(); }; friend class tl_throwable_ostream; @@ -764,6 +768,8 @@ namespace basictl { std::byte *ptr{}; std::byte *end_block{}; + bool sync_in_destructor = true; + void grow_buffer(); bool store_data(const void *vdata, size_t size); diff --git a/pkg/basictl_cpp/io_streams.cpp b/pkg/basictl_cpp/io_streams.cpp index b605eea63..623d2763f 100644 --- a/pkg/basictl_cpp/io_streams.cpp +++ b/pkg/basictl_cpp/io_streams.cpp @@ -8,6 +8,7 @@ namespace basictl { tl_istream::tl_istream(tl_throwable_istream &from) : provider(nullptr) { from.pass_data(*this); + this->sync_in_destructor = false; } bool tl_istream::string_read(std::string &value) noexcept { @@ -197,6 +198,7 @@ namespace basictl { tl_ostream::tl_ostream(tl_throwable_ostream &from) : provider(nullptr) { from.pass_data(*this); + this->sync_in_destructor = false; } bool tl_ostream::string_write(const std::string &value) { diff --git a/pkg/basictl_cpp/io_streams.h b/pkg/basictl_cpp/io_streams.h index 47fcc4e05..447afc97f 100644 --- a/pkg/basictl_cpp/io_streams.h +++ b/pkg/basictl_cpp/io_streams.h @@ -24,7 +24,7 @@ namespace basictl { tl_istream &operator=(tl_istream &&) = delete; - ~tl_istream() { sync(); }; + ~tl_istream() { if (sync_in_destructor) sync(); }; friend class tl_throwable_istream; @@ -132,6 +132,8 @@ namespace basictl { const std::byte *ptr{}; const std::byte *end_block{}; + bool sync_in_destructor = true; + void grow_buffer() noexcept; bool ensure_byte() noexcept; @@ -161,7 +163,7 @@ namespace basictl { tl_ostream &operator=(tl_ostream &&) = delete; - ~tl_ostream() { sync(); }; + ~tl_ostream() { if (this->sync_in_destructor) sync(); }; friend class tl_throwable_ostream; @@ -244,6 +246,8 @@ namespace basictl { std::byte *ptr{}; std::byte *end_block{}; + bool sync_in_destructor = true; + void grow_buffer(); bool store_data(const void *vdata, size_t size);