Core/MemoryPool: Remake memory pool

This commit is contained in:
Jérôme Leclercq
2022-02-20 16:00:32 +01:00
parent c3ace0dadc
commit 29c798a683
7 changed files with 292 additions and 183 deletions

View File

@@ -311,9 +311,11 @@ namespace Nz
ENetPacketRef ENetHost::AllocatePacket(ENetPacketFlags flags)
{
ENetPacketRef enetPacket = m_packetPool.New<ENetPacket>();
std::size_t poolIndex;
ENetPacketRef enetPacket = m_packetPool.Allocate(poolIndex);
enetPacket->flags = flags;
enetPacket->owner = &m_packetPool;
enetPacket->poolIndex = poolIndex;
enetPacket.m_pool = &m_packetPool;
return enetPacket;
}

View File

@@ -14,7 +14,10 @@ namespace Nz
if (m_packet)
{
if (--m_packet->referenceCount == 0)
m_packet->owner->Delete(m_packet);
{
assert(m_pool);
m_pool->Free(m_packet->poolIndex);
}
}
m_packet = packet;