Ticket #7156: bufferstream.hpp.patch

File bufferstream.hpp.patch, 2.9 KB (added by Jonathan Jones <jonathan.jones@…>, 10 years ago)

Patch which seems to fix the leak.

  • boost/boost/interprocess/streams/bufferstream.hpp

     
    263263   typedef typename std::basic_ios<char_type, CharTraits>::traits_type  traits_type;
    264264
    265265   private:
    266    typedef std::basic_ios<char_type, CharTraits>                basic_ios_t;
    267266   typedef std::basic_istream<char_type, CharTraits>            base_t;
    268267
    269268   public:
    270269   //!Constructor.
    271270   //!Does not throw.
    272271   basic_ibufferstream(std::ios_base::openmode mode = std::ios_base::in)
    273       :  basic_ios_t(), base_t(0), m_buf(mode | std::ios_base::in)
    274       {  basic_ios_t::init(&m_buf); }
     272      :  base_t(&m_buf), m_buf(mode | std::ios_base::in)
     273      { }
    275274
    276275   //!Constructor. Assigns formatting buffer.
    277276   //!Does not throw.
    278277   basic_ibufferstream(const CharT *buffer, std::size_t length,
    279278                          std::ios_base::openmode mode = std::ios_base::in)
    280       :  basic_ios_t(), base_t(0),
     279      :  base_t(&m_buf),
    281280         m_buf(const_cast<CharT*>(buffer), length, mode | std::ios_base::in)
    282       {  basic_ios_t::init(&m_buf); }
     281      { }
    283282
    284283   ~basic_ibufferstream(){};
    285284
     
    321320
    322321   /// @cond
    323322   private:
    324    typedef std::basic_ios<char_type, CharTraits>      basic_ios_t;
    325323   typedef std::basic_ostream<char_type, CharTraits>  base_t;
    326324   /// @endcond
    327325   public:
    328326   //!Constructor.
    329327   //!Does not throw.
    330328   basic_obufferstream(std::ios_base::openmode mode = std::ios_base::out)
    331       :  basic_ios_t(), base_t(0), m_buf(mode | std::ios_base::out)
    332       {  basic_ios_t::init(&m_buf); }
     329      :  base_t(&m_buf), m_buf(mode | std::ios_base::out)
     330      { }
    333331
    334332   //!Constructor. Assigns formatting buffer.
    335333   //!Does not throw.
    336334   basic_obufferstream(CharT *buffer, std::size_t length,
    337335                       std::ios_base::openmode mode = std::ios_base::out)
    338       :  basic_ios_t(), base_t(0),
     336      :  base_t(&m_buf),
    339337         m_buf(buffer, length, mode | std::ios_base::out)
    340       {  basic_ios_t::init(&m_buf); }
     338      { }
    341339
    342340   ~basic_obufferstream(){}
    343341
     
    381379
    382380   /// @cond
    383381   private:
    384    typedef std::basic_ios<char_type, CharTraits>                 basic_ios_t;
    385382   typedef std::basic_iostream<char_type, CharTraits>            base_t;
    386383   /// @endcond
    387384
     
    390387   //!Does not throw.
    391388   basic_bufferstream(std::ios_base::openmode mode
    392389                      = std::ios_base::in | std::ios_base::out)
    393       :  basic_ios_t(), base_t(0), m_buf(mode)
    394       {  basic_ios_t::init(&m_buf); }
     390      : base_t(&m_buf), m_buf(mode)
     391      { }
    395392
    396393   //!Constructor. Assigns formatting buffer.
    397394   //!Does not throw.
    398395   basic_bufferstream(CharT *buffer, std::size_t length,
    399396                      std::ios_base::openmode mode
    400397                        = std::ios_base::in | std::ios_base::out)
    401       :  basic_ios_t(), base_t(0), m_buf(buffer, length, mode)
    402       {  basic_ios_t::init(&m_buf); }
     398      : base_t(&m_buf), m_buf(buffer, length, mode)
     399      { }
    403400
    404401   ~basic_bufferstream(){}
    405402