Added NullStream class that automatically creates and delete the NullStreamBuffer, thus fixing a memory leak
This commit is contained in:
parent
7a7ee85f69
commit
f17b307305
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user