clang-format
This commit is contained in:
@@ -34,37 +34,33 @@
|
||||
|
||||
#include "pool.h"
|
||||
|
||||
unsigned
|
||||
poolalloc(struct poolctl *pool)
|
||||
{
|
||||
uint32_t mask;
|
||||
unsigned j, i;
|
||||
unsigned poolalloc(struct poolctl *pool) {
|
||||
uint32_t mask;
|
||||
unsigned j, i;
|
||||
|
||||
assert(pool->max % 32 == 0);
|
||||
for (j=0; j<pool->max/32; j++) {
|
||||
for (mask=1, i=0; i<32; mask<<=1, i++) {
|
||||
if ((pool->inuse[j] & mask) == 0) {
|
||||
pool->inuse[j] |= mask;
|
||||
return j*32 + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
errx(1, "Too many %s -- increase %s in %s",
|
||||
pool->itemtype, pool->maxname, pool->file);
|
||||
return 0;
|
||||
assert(pool->max % 32 == 0);
|
||||
for (j = 0; j < pool->max / 32; j++) {
|
||||
for (mask = 1, i = 0; i < 32; mask <<= 1, i++) {
|
||||
if ((pool->inuse[j] & mask) == 0) {
|
||||
pool->inuse[j] |= mask;
|
||||
return j * 32 + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
errx(1, "Too many %s -- increase %s in %s", pool->itemtype, pool->maxname,
|
||||
pool->file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
poolfree(struct poolctl *pool, unsigned num)
|
||||
{
|
||||
uint32_t mask;
|
||||
unsigned pos;
|
||||
void poolfree(struct poolctl *pool, unsigned num) {
|
||||
uint32_t mask;
|
||||
unsigned pos;
|
||||
|
||||
assert(num < pool->max);
|
||||
assert(num < pool->max);
|
||||
|
||||
pos = num / 32;
|
||||
mask = 1 << (num % 32);
|
||||
pos = num / 32;
|
||||
mask = 1 << (num % 32);
|
||||
|
||||
assert(pool->inuse[pos] & mask);
|
||||
pool->inuse[pos] &= ~(uint32_t)mask;
|
||||
assert(pool->inuse[pos] & mask);
|
||||
pool->inuse[pos] &= ~(uint32_t)mask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user