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
0
/// 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
0
    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
0
	AutoAllocation::AutoAllocation(Allocator& allocator, size_t size, const AllocationDetails& details)
	: allocator(allocator)
	{
		void* pointer = allocator.Allocate(details, size);
		address = allocator.ToIntPtr(pointer);
	}