当前位置: 首页>>代码示例>>C++>>正文


C++ DataBuffer::GetSize方法代码示例

本文整理汇总了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
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:54,代码来源:hotheap.cpp

示例2: GetSerializedLength

std::size_t VarInt::GetSerializedLength() const {
    DataBuffer buffer;
    buffer << *this;
    return buffer.GetSize();
}
开发者ID:plushmonkey,项目名称:mclib,代码行数:5,代码来源:VarInt.cpp


注:本文中的DataBuffer::GetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。