Lines Matching refs:pool
86 free_object (struct mempool *pool, void *object) in free_object() argument
90 obj->next = pool->free_list; in free_object()
91 pool->free_list = obj; in free_object()
92 ++pool->num_free; in free_object()
96 add_memory (struct mempool *pool, char *mem, size_t size, size_t obj_size) in add_memory() argument
101 free_object (pool, obj); in add_memory()
105 expand (struct mempool *pool) in expand() argument
110 size = pool->chunk_size; in expand()
114 size = UNW_ALIGN(pool->obj_size, pg_size); in expand()
119 size = pool->obj_size; in expand()
123 add_memory (pool, mem, size, pool->obj_size); in expand()
127 mempool_init (struct mempool *pool, size_t obj_size, size_t reserve) in mempool_init() argument
132 memset (pool, 0, sizeof (*pool)); in mempool_init()
134 lock_init (&pool->lock); in mempool_init()
146 pool->obj_size = obj_size; in mempool_init()
147 pool->reserve = reserve; in mempool_init()
148 pool->chunk_size = UNW_ALIGN(2*reserve*obj_size, pg_size); in mempool_init()
150 expand (pool); in mempool_init()
154 mempool_alloc (struct mempool *pool) in mempool_alloc() argument
159 lock_acquire (&pool->lock, saved_mask); in mempool_alloc()
161 if (pool->num_free <= pool->reserve) in mempool_alloc()
162 expand (pool); in mempool_alloc()
164 assert (pool->num_free > 0); in mempool_alloc()
166 --pool->num_free; in mempool_alloc()
167 obj = pool->free_list; in mempool_alloc()
168 pool->free_list = obj->next; in mempool_alloc()
170 lock_release (&pool->lock, saved_mask); in mempool_alloc()
175 mempool_free (struct mempool *pool, void *object) in mempool_free() argument
179 lock_acquire (&pool->lock, saved_mask); in mempool_free()
181 free_object (pool, object); in mempool_free()
183 lock_release (&pool->lock, saved_mask); in mempool_free()