Lines Matching defs:pool

1 /*	$NetBSD: pool.c,v 1.1 2024/02/18 20:57:50 christos Exp $	*/
21 #include <isc/pool.h>
35 void **pool;
44 isc_pool_t *pool;
46 pool = isc_mem_get(mctx, sizeof(*pool));
47 pool->count = count;
48 pool->free = NULL;
49 pool->init = NULL;
50 pool->initarg = NULL;
51 pool->mctx = NULL;
52 isc_mem_attach(mctx, &pool->mctx);
53 pool->pool = isc_mem_get(mctx, count * sizeof(void *));
54 memset(pool->pool, 0, count * sizeof(void *));
56 *poolp = pool;
64 isc_pool_t *pool = NULL;
70 /* Allocate the pool structure */
71 result = alloc_pool(mctx, count, &pool);
76 pool->free = release;
77 pool->init = init;
78 pool->initarg = initarg;
80 /* Populate the pool */
82 result = init(&pool->pool[i], initarg);
84 isc_pool_destroy(&pool);
89 *poolp = pool;
94 isc_pool_get(isc_pool_t *pool) {
95 return (pool->pool[isc_random_uniform(pool->count)]);
99 isc_pool_count(isc_pool_t *pool) {
100 REQUIRE(pool != NULL);
101 return (pool->count);
108 isc_pool_t *pool;
113 pool = *sourcep;
115 if (count > pool->count) {
119 /* Allocate a new pool structure */
120 result = alloc_pool(pool->mctx, count, &newpool);
125 newpool->free = pool->free;
126 newpool->init = pool->init;
127 newpool->initarg = pool->initarg;
130 for (i = pool->count; i < count; i++) {
131 result = newpool->init(&newpool->pool[i],
139 /* Copy over the objects from the old pool */
140 for (i = 0; i < pool->count; i++) {
141 newpool->pool[i] = pool->pool[i];
142 pool->pool[i] = NULL;
145 isc_pool_destroy(&pool);
146 pool = newpool;
149 *targetp = pool;
156 isc_pool_t *pool = *poolp;
158 for (i = 0; i < pool->count; i++) {
159 if (pool->free != NULL && pool->pool[i] != NULL) {
160 pool->free(&pool->pool[i]);
163 isc_mem_put(pool->mctx, pool->pool, pool->count * sizeof(void *));
164 isc_mem_putanddetach(&pool->mctx, pool, sizeof(*pool));