本文整理汇总了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 );
}
示例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;
}
示例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;
}
示例4: allocator
AutoAllocation::AutoAllocation(Allocator& allocator, size_t size, const AllocationDetails& details)
: allocator(allocator)
{
void* pointer = allocator.Allocate(details, size);
address = allocator.ToIntPtr(pointer);
}