From f21a6470b16b7e0f44d56ec9d90c44fd48e418c5 Mon Sep 17 00:00:00 2001 From: Abdelhakim Qbaich Date: Sun, 5 Apr 2026 19:27:19 -0400 Subject: [PATCH] Mark max_blen as static constexpr and use in test --- .../streamers/oasis/unit_tests/dbOASISReaderTests.cc | 3 ++- src/tl/tl/tlDeflate.h | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc index a577ca093..7f2c11da7 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc @@ -26,6 +26,7 @@ #include "dbLayoutDiff.h" #include "dbTextWriter.h" #include "dbTestSupport.h" +#include "tlDeflate.h" #include "tlLog.h" #include "tlUnitTest.h" #include "tlStream.h" @@ -706,7 +707,7 @@ TEST(CBlockLargePropertyString) unsigned int layer = layout_org.insert_layer (db::LayerProperties (1, 0)); db::Cell &top = layout_org.cell (layout_org.add_cell ("TOP")); - std::string large_value (42000, 'a'); + std::string large_value (tl::InflateFilter::max_blen () + 1, 'a'); db::PropertiesSet ps; ps.insert (db::property_names_id (tl::Variant ("blob")), tl::Variant (large_value)); diff --git a/src/tl/tl/tlDeflate.h b/src/tl/tl/tlDeflate.h index 3fee4ebcd..8c7a2d5fd 100644 --- a/src/tl/tl/tlDeflate.h +++ b/src/tl/tl/tlDeflate.h @@ -195,6 +195,8 @@ private: class TL_PUBLIC InflateFilter { public: + static constexpr size_t buffer_size = 65536; + /** * @brief Constructor * @@ -218,9 +220,9 @@ public: /** * @brief Obtain the maximum number of bytes available for a single get() call */ - size_t max_blen () const + static constexpr size_t max_blen () { - return sizeof (m_buffer) / 2 - 1; + return buffer_size / 2 - 1; } /** @@ -240,7 +242,7 @@ public: private: BitStream m_input; - char m_buffer[65536]; + char m_buffer[buffer_size]; unsigned int m_b_insert; unsigned int m_b_read; bool m_at_end;