Mario Charest
09/17/2008 5:31 PM
post13594
|
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.
|
|
|