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


C++ Allocator::Allocate方法代码示例

本文整理汇总了C++中Allocator::Allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ Allocator::Allocate方法的具体用法?C++ Allocator::Allocate怎么用?C++ Allocator::Allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Allocator的用法示例。


在下文中一共展示了Allocator::Allocate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

    PacketProcessor::PacketProcessor( Allocator & allocator, uint32_t protocolId, int maxPacketSize )
    {
        m_allocator = &allocator;

        m_protocolId = protocolId;

        m_error = PACKET_PROCESSOR_ERROR_NONE;

        m_maxPacketSize = maxPacketSize + ( ( maxPacketSize % 4 ) ? ( 4 - ( maxPacketSize % 4 ) ) : 0 );
        
        assert( m_maxPacketSize % 4 == 0 );
        assert( m_maxPacketSize >= maxPacketSize );

        m_absoluteMaxPacketSize = maxPacketSize + MaxPrefixBytes + CryptoOverhead;

        m_context = NULL;

        m_packetBuffer = (uint8_t*) allocator.Allocate( m_absoluteMaxPacketSize );

        m_scratchBuffer = (uint8_t*) allocator.Allocate( m_absoluteMaxPacketSize );
    }
开发者ID:NullSoldier,项目名称:libyojimbo,代码行数:21,代码来源:yojimbo_packet_processor.cpp

示例2:

/// Allocates a memory block of the requested size. The blocks are created from
///	the fixed block allocators.
///	@param[in] size - the client requested size of the block.
/// @return	A pointer to the client's memory block.
extern "C" void *xmalloc(size_t size)
{
	lock_get();

	// Allocate a raw memory block 
	Allocator* allocator = xallocator_get_allocator(size);
	void* blockMemoryPtr = allocator->Allocate(size);

	lock_release();

	// Set the block Allocator* within the raw memory block region
	void* clientsMemoryPtr = set_block_allocator(blockMemoryPtr, allocator);
	return clientsMemoryPtr;
}
开发者ID:IonutCava,项目名称:trunk,代码行数:18,代码来源:xallocator.cpp

示例3: assert

    NetworkSimulator::NetworkSimulator( Allocator & allocator, int numPackets )
    {
        m_allocator = &allocator;

        assert( numPackets > 0 );

        m_numPacketEntries = numPackets;

        m_packetEntries = (PacketEntry*) allocator.Allocate( sizeof( PacketEntry ) * numPackets );

        memset( m_packetEntries, 0, sizeof( PacketEntry ) * numPackets );

        m_time = 0.0;
        m_latency = 0.0f;
        m_jitter = 0.0f;
        m_packetLoss = 0.0f;
        m_duplicates = 0.0f;
        m_currentIndex = 0;
    }
开发者ID:Cloven,项目名称:libyojimbo,代码行数:19,代码来源:yojimbo_simulator.cpp

示例4: allocator

	AutoAllocation::AutoAllocation(Allocator& allocator, size_t size, const AllocationDetails& details)
	: allocator(allocator)
	{
		void* pointer = allocator.Allocate(details, size);
		address = allocator.ToIntPtr(pointer);
	}
开发者ID:jjuran,项目名称:classix,代码行数:6,代码来源:Allocator.cpp


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