Added NullStream class that automatically creates and delete the NullStreamBuffer, thus fixing a memory leak

This commit is contained in:
Robert Osfield 2008-08-05 15:11:47 +00:00
parent 7a7ee85f69
commit f17b307305

View File

@ -93,10 +93,22 @@ class NullStreamBuffer : public std::streambuf
} }
}; };
struct NullStream : public std::ostream
{
NullStream():
std::ostream(new NullStreamBuffer) {}
virtual ~NullStream()
{
delete rdbuf();
rdbuf(0);
}
};
std::ostream& osg::notify(const osg::NotifySeverity severity) std::ostream& osg::notify(const osg::NotifySeverity severity)
{ {
// set up global notify null stream for inline notify // set up global notify null stream for inline notify
static std::ostream s_NotifyNulStream(new NullStreamBuffer()); static NullStream s_NotifyNulStream;
static bool initialized = false; static bool initialized = false;
if (!initialized) if (!initialized)