2019-09-12 20:53:24 +02:00
|
|
|
#include "lplanes_pool.h"
|
|
|
|
|
|
|
|
LPlanesPool::LPlanesPool()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
|
|
|
|
// preallocate the vectors to a reasonable size
|
|
|
|
for (int n=0; n<POOL_MAX; n++)
|
|
|
|
{
|
|
|
|
m_Planes[n].reserve(32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LPlanesPool::Reset()
|
|
|
|
{
|
2019-09-25 08:48:35 +02:00
|
|
|
for (int n=0; n<POOL_MAX; n++)
|
|
|
|
{
|
|
|
|
m_ucFreeList[n] = POOL_MAX - n - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_uiNumFree = POOL_MAX;
|
2019-09-12 20:53:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int LPlanesPool::Request()
|
|
|
|
{
|
2019-09-25 08:48:35 +02:00
|
|
|
if (!m_uiNumFree)
|
2019-09-12 20:53:24 +02:00
|
|
|
return -1;
|
|
|
|
|
2019-09-25 08:48:35 +02:00
|
|
|
m_uiNumFree--;
|
|
|
|
return m_ucFreeList[m_uiNumFree];
|
2019-09-12 20:53:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void LPlanesPool::Free(unsigned int ui)
|
|
|
|
{
|
|
|
|
assert (ui <= POOL_MAX);
|
2019-09-25 08:48:35 +02:00
|
|
|
assert (m_uiNumFree < POOL_MAX);
|
2019-09-12 20:53:24 +02:00
|
|
|
|
2019-09-25 08:48:35 +02:00
|
|
|
m_ucFreeList[m_uiNumFree] = ui;
|
|
|
|
m_uiNumFree++;
|
2019-09-12 20:53:24 +02:00
|
|
|
}
|