Lines Matching refs:pool
68 ba_init(struct bitalloc *pool, int size, bool free) in ba_init() argument
70 bitalloc_word_t *mem = (bitalloc_word_t *)pool; in ba_init()
74 pool->size = 0; in ba_init()
86 pool->size = size; in ba_init()
101 pool->storage[offset++] = words[--lev]; in ba_init()
107 ba_free(pool, i); in ba_init()
114 ba_alloc_helper(struct bitalloc *pool, in ba_alloc_helper() argument
121 bitalloc_word_t *storage = &pool->storage[offset]; in ba_alloc_helper()
130 if (pool->size > size) { in ba_alloc_helper()
131 r = ba_alloc_helper(pool, in ba_alloc_helper()
140 pool->free_count--; in ba_alloc_helper()
152 ba_alloc(struct bitalloc *pool) in ba_alloc() argument
156 return ba_alloc_helper(pool, 0, 1, 32, 0, &clear); in ba_alloc()
187 ba_alloc_reverse_helper(struct bitalloc *pool, in ba_alloc_reverse_helper() argument
194 bitalloc_word_t *storage = &pool->storage[offset]; in ba_alloc_reverse_helper()
203 if (pool->size > size) { in ba_alloc_reverse_helper()
204 r = ba_alloc_reverse_helper(pool, in ba_alloc_reverse_helper()
213 pool->free_count--; in ba_alloc_reverse_helper()
225 ba_alloc_reverse(struct bitalloc *pool) in ba_alloc_reverse() argument
229 return ba_alloc_reverse_helper(pool, 0, 1, 32, 0, &clear); in ba_alloc_reverse()
233 ba_alloc_index_helper(struct bitalloc *pool, in ba_alloc_index_helper() argument
240 bitalloc_word_t *storage = &pool->storage[offset]; in ba_alloc_index_helper()
244 if (pool->size > size) in ba_alloc_index_helper()
245 r = ba_alloc_index_helper(pool, in ba_alloc_index_helper()
261 pool->free_count--; in ba_alloc_index_helper()
274 ba_alloc_index(struct bitalloc *pool, int index) in ba_alloc_index() argument
279 if (index < 0 || index >= (int)pool->size) in ba_alloc_index()
282 if (ba_alloc_index_helper(pool, 0, 1, 32, &index_copy, &clear) >= 0) in ba_alloc_index()
289 ba_inuse_helper(struct bitalloc *pool, in ba_inuse_helper() argument
295 bitalloc_word_t *storage = &pool->storage[offset]; in ba_inuse_helper()
299 if (pool->size > size) in ba_inuse_helper()
300 r = ba_inuse_helper(pool, in ba_inuse_helper()
318 ba_inuse(struct bitalloc *pool, int index) in ba_inuse() argument
320 if (index < 0 || index >= (int)pool->size) in ba_inuse()
323 return ba_inuse_helper(pool, 0, 1, 32, &index) == 0; in ba_inuse()
327 ba_free_helper(struct bitalloc *pool, in ba_free_helper() argument
333 bitalloc_word_t *storage = &pool->storage[offset]; in ba_free_helper()
337 if (pool->size > size) in ba_free_helper()
338 r = ba_free_helper(pool, in ba_free_helper()
352 pool->free_count++; in ba_free_helper()
362 ba_free(struct bitalloc *pool, int index) in ba_free() argument
364 if (index < 0 || index >= (int)pool->size) in ba_free()
367 return ba_free_helper(pool, 0, 1, 32, &index); in ba_free()
371 ba_inuse_free(struct bitalloc *pool, int index) in ba_inuse_free() argument
373 if (index < 0 || index >= (int)pool->size) in ba_inuse_free()
376 return ba_free_helper(pool, 0, 1, 32, &index) + 1; in ba_inuse_free()
380 ba_free_count(struct bitalloc *pool) in ba_free_count() argument
382 return (int)pool->free_count; in ba_free_count()
385 int ba_inuse_count(struct bitalloc *pool) in ba_inuse_count() argument
387 return (int)(pool->size) - (int)(pool->free_count); in ba_inuse_count()
391 ba_find_next_helper(struct bitalloc *pool, in ba_find_next_helper() argument
398 bitalloc_word_t *storage = &pool->storage[offset]; in ba_find_next_helper()
401 if (pool->size > size) in ba_find_next_helper()
402 r = ba_find_next_helper(pool, in ba_find_next_helper()
421 if (r >= (int)pool->size) in ba_find_next_helper()
428 while ((int)pool->size > bit_index) { in ba_find_next_helper()
434 if (r >= (int)pool->size) in ba_find_next_helper()
446 pool->free_count++; in ba_find_next_helper()
454 ba_find_next_inuse(struct bitalloc *pool, int index) in ba_find_next_inuse() argument
457 index >= (int)pool->size || in ba_find_next_inuse()
458 pool->free_count == pool->size) in ba_find_next_inuse()
461 return ba_find_next_helper(pool, 0, 1, 32, &index, 0); in ba_find_next_inuse()
465 ba_find_next_inuse_free(struct bitalloc *pool, int index) in ba_find_next_inuse_free() argument
468 index >= (int)pool->size || in ba_find_next_inuse_free()
469 pool->free_count == pool->size) in ba_find_next_inuse_free()
472 return ba_find_next_helper(pool, 0, 1, 32, &index, 1); in ba_find_next_inuse_free()