diff --git a/src/fdr/fdr_confirm_compile.cpp b/src/fdr/fdr_confirm_compile.cpp index d6eb6640..319141c4 100644 --- a/src/fdr/fdr_confirm_compile.cpp +++ b/src/fdr/fdr_confirm_compile.cpp @@ -337,6 +337,7 @@ bytecode_ptr getFDRConfirm(const vector &lits, size_t actual_size = ROUNDUP_N((size_t)(ptr - fdrc_base), alignof(FDRConfirm)); assert(actual_size <= size); + fdrc.shrink(actual_size); return fdrc; } diff --git a/src/util/bytecode_ptr.h b/src/util/bytecode_ptr.h index ace5063c..15d3e2fe 100644 --- a/src/util/bytecode_ptr.h +++ b/src/util/bytecode_ptr.h @@ -101,6 +101,19 @@ public: swap(alignment, other.alignment); } + /** + * \brief Reduces the apparent size of the memory region. Note that this + * does not reallocate and copy, it just changes the value returned by + * size(). + */ + void shrink(size_t size) { + if (size > bytes) { + assert(0); + throw std::logic_error("Must shrink to a smaller value"); + } + bytes = size; + } + /** \brief Returns size of the memory region in bytes. */ size_t size() const { return bytes; }