Lines Matching defs:pool

19 #include <isc/pool.h>
32 void ** pool;
41 isc_pool_t *pool;
43 pool = isc_mem_get(mctx, sizeof(*pool));
44 if (pool == NULL)
46 pool->count = count;
47 pool->free = NULL;
48 pool->init = NULL;
49 pool->initarg = NULL;
50 pool->mctx = NULL;
51 isc_mem_attach(mctx, &pool->mctx);
52 pool->pool = isc_mem_get(mctx, count * sizeof(void *));
53 if (pool->pool == NULL) {
54 isc_mem_put(mctx, pool, sizeof(*pool));
57 memset(pool->pool, 0, count * sizeof(void *));
59 *poolp = pool;
69 isc_pool_t *pool = NULL;
75 /* Allocate the pool structure */
76 result = alloc_pool(mctx, count, &pool);
80 pool->free = release;
81 pool->init = init;
82 pool->initarg = initarg;
84 /* Populate the pool */
86 result = init(&pool->pool[i], initarg);
88 isc_pool_destroy(&pool);
93 *poolp = pool;
98 isc_pool_get(isc_pool_t *pool) {
101 return (pool->pool[i % pool->count]);
105 isc_pool_count(isc_pool_t *pool) {
106 REQUIRE(pool != NULL);
107 return (pool->count);
115 isc_pool_t *pool;
120 pool = *sourcep;
121 if (count > pool->count) {
125 /* Allocate a new pool structure */
126 result = alloc_pool(pool->mctx, count, &newpool);
130 newpool->free = pool->free;
131 newpool->init = pool->init;
132 newpool->initarg = pool->initarg;
134 /* Copy over the objects from the old pool */
135 for (i = 0; i < pool->count; i++) {
136 newpool->pool[i] = pool->pool[i];
137 pool->pool[i] = NULL;
141 for (i = pool->count; i < count; i++) {
142 result = pool->init(&newpool->pool[i], pool->initarg);
144 isc_pool_destroy(&pool);
149 isc_pool_destroy(&pool);
150 pool = newpool;
154 *targetp = pool;
161 isc_pool_t *pool = *poolp;
162 for (i = 0; i < pool->count; i++) {
163 if (pool->free != NULL && pool->pool[i] != NULL)
164 pool->free(&pool->pool[i]);
166 isc_mem_put(pool->mctx, pool->pool, pool->count * sizeof(void *));
167 isc_mem_putanddetach(&pool->mctx, pool, sizeof(*pool));