Lines Matching defs:pool
615 /// int nk_init_custom(struct nk_context *ctx, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *font);
627 NK_API int nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
4122 struct nk_allocator pool;
5601 struct nk_pool pool;
5873 /* pool */
5874 NK_LIB void nk_pool_init(struct nk_pool *pool, struct nk_allocator *alloc, unsigned int capacity);
5875 NK_LIB void nk_pool_free(struct nk_pool *pool);
5876 NK_LIB void nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size);
5877 NK_LIB struct nk_page_element *nk_pool_alloc(struct nk_pool *pool);
8047 b->pool = *a;
8101 if (!b || !size || !b->pool.alloc || !b->pool.free)
8105 temp = b->pool.alloc(b->pool.userdata, b->memory.ptr, capacity);
8112 b->pool.free(b->pool.userdata, b->memory.ptr);
8160 NK_ASSERT(b->pool.alloc && b->pool.free);
8161 if (b->type != NK_BUFFER_DYNAMIC || !b->pool.alloc || !b->pool.free)
8238 if (!b->pool.free) return;
8239 NK_ASSERT(b->pool.free);
8240 b->pool.free(b->pool.userdata, b->memory.ptr);
15003 struct nk_buffer *pool, const struct nk_user_font *font)
15006 NK_ASSERT(pool);
15007 if (!cmds || !pool) return 0;
15011 if (pool->type == NK_BUFFER_FIXED) {
15012 /* take memory from buffer and alloc fixed pool */
15013 nk_pool_init_fixed(&ctx->pool, pool->memory.ptr, pool->memory.size);
15015 /* create dynamic pool from buffer allocator */
15016 struct nk_allocator *alloc = &pool->pool;
15017 nk_pool_init(&ctx->pool, alloc, NK_POOL_DEFAULT_CAPACITY);
15030 nk_pool_init(&ctx->pool, alloc, NK_POOL_DEFAULT_CAPACITY);
15051 nk_pool_free(&ctx->pool);
15312 nk_pool_init(struct nk_pool *pool, struct nk_allocator *alloc,
15315 nk_zero(pool, sizeof(*pool));
15316 pool->alloc = *alloc;
15317 pool->capacity = capacity;
15318 pool->type = NK_BUFFER_DYNAMIC;
15319 pool->pages = 0;
15322 nk_pool_free(struct nk_pool *pool)
15324 struct nk_page *iter = pool->pages;
15325 if (!pool) return;
15326 if (pool->type == NK_BUFFER_FIXED) return;
15329 pool->alloc.free(pool->alloc.userdata, iter);
15334 nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size)
15336 nk_zero(pool, sizeof(*pool));
15339 pool->capacity = (unsigned)(size - sizeof(struct nk_page)) / sizeof(struct nk_page_element);
15340 pool->pages = (struct nk_page*)memory;
15341 pool->type = NK_BUFFER_FIXED;
15342 pool->size = size;
15345 nk_pool_alloc(struct nk_pool *pool)
15347 if (!pool->pages || pool->pages->size >= pool->capacity) {
15350 if (pool->type == NK_BUFFER_FIXED) {
15351 NK_ASSERT(pool->pages);
15352 if (!pool->pages) return 0;
15353 NK_ASSERT(pool->pages->size < pool->capacity);
15358 page = (struct nk_page*)pool->alloc.alloc(pool->alloc.userdata,0, size);
15359 page->next = pool->pages;
15360 pool->pages = page;
15363 } return &pool->pages->win[pool->pages->size++];
15384 /* allocate page element from memory pool */
15385 elem = nk_pool_alloc(&ctx->pool);
15416 /* we have a pool so just add to free list */
25737 /// - 2016/07/29 (1.03.0) - Moved the window/table pool into the header part to
25739 /// allocate the pool.