Lines Matching refs:pool
38 void memory_pool_init(struct memory_pool * pool)
40 memset(pool, 0, sizeof(struct memory_pool));
44 void memory_pool_destroy(struct memory_pool * pool)
46 while(pool->blocks) {
47 struct memory_block * block = pool->blocks;
48 pool->blocks = block->next;
53 static void refill_pool(struct memory_pool * pool)
55 unsigned int blocksize = pool->total_allocated;
62 newblock->next = pool->blocks;
63 pool->blocks = newblock;
65 pool->head = (unsigned char*)(newblock + 1);
66 pool->end = ((unsigned char*)newblock) + blocksize;
67 pool->total_allocated += blocksize;
71 void * memory_pool_malloc(struct memory_pool * pool, unsigned int bytes)
76 if (pool->head + bytes > pool->end)
77 refill_pool(pool);
79 assert(pool->head + bytes <= pool->end);
81 ptr = pool->head;
83 pool->head += bytes;
84 pool->head = (unsigned char*)(((unsigned long)pool->head + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1));
90 block->next = pool->blocks;
91 pool->blocks = block;