0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

ID Maps are checking whether their pool is locked

This commit is contained in:
Maria Matejka 2023-05-08 15:13:49 +02:00
parent fcbf22d1f6
commit 2623b7ba5d
2 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,7 @@ idm_init(struct idm *m, pool *p, uint size)
m->used = 1;
m->size = size;
m->data = mb_allocz(p, m->size * sizeof(u32));
m->pool = p;
/* ID 0 is reserved */
m->data[0] = 1;
@ -34,6 +35,8 @@ idm_alloc(struct idm *m)
{
uint i, j;
ASSERT_DIE(DG_IS_LOCKED(m->pool->domain));
for (i = m->pos; i < m->size; i++)
if (m->data[i] != 0xffffffff)
goto found;
@ -67,6 +70,8 @@ found:
void
idm_free(struct idm *m, u32 id)
{
ASSERT_DIE(DG_IS_LOCKED(m->pool->domain));
uint i = id / 32;
uint j = id % 32;

View File

@ -12,6 +12,7 @@
struct idm
{
pool *pool;
u32 *data;
u32 pos;
u32 used;