/**
* Per-kind array of free context ids
*/
- bool* ctxids[TKM_CTX_MAX];
+ int* ctxids[TKM_CTX_MAX];
/**
* Per-kind context limits.
this->locks[kind]->write_lock(this->locks[kind]);
for (j = 0; j < this->limits[kind]; j++)
{
- if (!this->ctxids[kind][j])
+ if (this->ctxids[kind][j] == 0)
{
- this->ctxids[kind][j] = true;
+ this->ctxids[kind][j] = 1;
id = j + 1;
break;
}
}
this->locks[kind]->write_lock(this->locks[kind]);
- this->ctxids[kind][idx] = false;
+ if (this->ctxids[kind][idx] > 0)
+ {
+ this->ctxids[kind][idx]--;
+ }
this->locks[kind]->unlock(this->locks[kind]);
return TRUE;
for (i = 0; i < TKM_CTX_MAX; i++)
{
this->limits[i] = limits[i];
- this->ctxids[i] = calloc(limits[i], sizeof(bool));
+ this->ctxids[i] = calloc(limits[i], sizeof(int));
this->locks[i] = rwlock_create(RWLOCK_TYPE_DEFAULT);
DBG2(DBG_LIB, "%N initialized, %llu slot(s)", tkm_context_kind_names, i,
limits[i]);