From 8dad674507a9e8d5ae6e3cb23df717ea0c41443b Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 10 Mar 2016 04:41:08 +1100 Subject: [PATCH] Allow seek to position 0 in a vectorstream with empty storage, always reserve 1k for core_file printf buffer --- src/lib/util/corefile.cpp | 1 + src/lib/util/vecstream.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp index fd98c8be59f..64169a606fc 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -613,6 +613,7 @@ int core_text_file::puts(char const *s) int core_text_file::vprintf(util::format_argument_pack const &args) { + m_printf_buffer.reserve(1024); m_printf_buffer.seekp(0, ovectorstream::beg); util::stream_format(m_printf_buffer, args); m_printf_buffer.put('\0'); diff --git a/src/lib/util/vecstream.h b/src/lib/util/vecstream.h index 498e35eac5e..bf144501253 100644 --- a/src/lib/util/vecstream.h +++ b/src/lib/util/vecstream.h @@ -116,7 +116,7 @@ public: void reserve(typename vector_type::size_type size) { - if ((m_mode & std::ios_base::out) && (m_storage.size() < size)) + if ((m_mode & std::ios_base::out) && (m_storage.capacity() < size)) { m_storage.reserve(size); adjust(); @@ -150,8 +150,8 @@ protected: bool const out(which & std::ios_base::out); if ((!in && !out) || (in && out && (std::ios_base::cur == dir)) || - (in && (!(m_mode & std::ios_base::in) || !this->gptr())) || - (out && (!(m_mode & std::ios_base::out) || !this->pptr()))) + (in && !(m_mode & std::ios_base::in)) || + (out && !(m_mode & std::ios_base::out))) { return pos_type(off_type(-1)); }