streams: add DataStream::GetMemoryUsage

This commit is contained in:
laanwj 2024-10-27 09:04:54 +01:00
parent c3a6722f34
commit 047b5e2af1
2 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/license/mit/.
#include <memusage.h>
#include <span.h>
#include <streams.h>
#include <util/fs_helpers.h>
@ -110,3 +111,8 @@ bool AutoFile::Truncate(unsigned size)
{
return ::TruncateFile(m_file, size);
}
size_t DataStream::GetMemoryUsage() const noexcept
{
return sizeof(*this) + memusage::DynamicUsage(vch);
}

View File

@ -277,6 +277,9 @@ public:
{
util::Xor(MakeWritableByteSpan(*this), MakeByteSpan(key));
}
/** Compute total memory usage of this object (own memory + any dynamic memory). */
size_t GetMemoryUsage() const noexcept;
};
template <typename IStream>