本文整理汇总了C++中DataBuffer::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBuffer::GetSize方法的具体用法?C++ DataBuffer::GetSize怎么用?C++ DataBuffer::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBuffer
的用法示例。
在下文中一共展示了DataBuffer::GetSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// --------------------------------------------------------------------------------------
//
// Initializes hot heap from its header and data.
// Provides limited debug-only validation of the structure.
//
__checkReturn
HRESULT
HotHeap::Initialize(
struct HotHeapHeader *pHotHeapHeader,
DataBuffer hotHeapData)
{
_ASSERTE(hotHeapData.GetDataPointerBehind() == reinterpret_cast<BYTE *>(pHotHeapHeader));
UINT32 nMaximumNegativeOffset = hotHeapData.GetSize();
if (pHotHeapHeader->m_nIndexTableStart_NegativeOffset > nMaximumNegativeOffset)
{
m_pHotHeapHeader = NULL;
Debug_ReportError("Invalid hot heap header format - invalid index table offset.");
return METADATA_E_INVALID_FORMAT;
}
if ((pHotHeapHeader->m_nIndexTableStart_NegativeOffset % 4) != 0)
{
m_pHotHeapHeader = NULL;
Debug_ReportError("Invalid hot heap header format - index table offset is not aligned.");
return METADATA_E_INVALID_FORMAT;
}
if (pHotHeapHeader->m_nValueOffsetTableStart_NegativeOffset > nMaximumNegativeOffset)
{
m_pHotHeapHeader = NULL;
Debug_ReportError("Invalid hot heap header format - invalid value offset table offset.");
return METADATA_E_INVALID_FORMAT;
}
if ((pHotHeapHeader->m_nValueOffsetTableStart_NegativeOffset % 4) != 0)
{
m_pHotHeapHeader = NULL;
Debug_ReportError("Invalid hot heap header format - value offset table offset is not aligned.");
return METADATA_E_INVALID_FORMAT;
}
// Index table has to be behind value offset table
if (pHotHeapHeader->m_nValueOffsetTableStart_NegativeOffset < pHotHeapHeader->m_nIndexTableStart_NegativeOffset)
{
m_pHotHeapHeader = NULL;
Debug_ReportError("Invalid hot heap header format - value offset table doesn't start before index table.");
return METADATA_E_INVALID_FORMAT;
}
if (pHotHeapHeader->m_nValueHeapStart_NegativeOffset > nMaximumNegativeOffset)
{
m_pHotHeapHeader = NULL;
Debug_ReportError("Invalid hot heap header format - invalid value heap offset.");
return METADATA_E_INVALID_FORMAT;
}
m_pHotHeapHeader = pHotHeapHeader;
return S_OK;
} // HotHeap::Initialize
示例2: GetSerializedLength
std::size_t VarInt::GetSerializedLength() const {
DataBuffer buffer;
buffer << *this;
return buffer.GetSize();
}