Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - init of std::ios: (1 Item)
   
init of std::ios  
I came the following code:;

 class MyStreamBuf: public std::streambuf
 {
    ...
 };

 class MyIOS: public virtual std::ios
 {
 public:
     MyIOS()
     {
         init(&_buf);
     }
 protected:
     MyStreamBuf _buf;
 };

But found that the init() would create a memory leak.    Shoud init be called or not, is this a bug in the library?  

Some comments in the code are saying:

// This is a workaround for a bug in the Microsoft
// implementation of iostreams.
//
// Calling basic_ios::init() multiple times for the
// same basic_ios instance results in a memory leak
// caused by the ios' locale being allocated more than
// once, each time overwriting the old pointer.

If complile under windows init becomes a macro that does nothing, under QNX it does get called but I creates a memory 
leak.