Lines Matching refs:pool

89   struct MemoryPool *pool;  in MHD_pool_create()  local
91 pool = malloc (sizeof (struct MemoryPool)); in MHD_pool_create()
92 if (NULL == pool) in MHD_pool_create()
96 pool->memory = MAP_FAILED; in MHD_pool_create()
99 pool->memory = mmap (NULL, max, PROT_READ | PROT_WRITE, in MHD_pool_create()
102 pool->memory = VirtualAlloc(NULL, max, MEM_COMMIT | MEM_RESERVE, in MHD_pool_create()
106 pool->memory = MAP_FAILED; in MHD_pool_create()
108 if ((pool->memory == MAP_FAILED) || (pool->memory == NULL)) in MHD_pool_create()
110 pool->memory = malloc (max); in MHD_pool_create()
111 if (pool->memory == NULL) in MHD_pool_create()
113 free (pool); in MHD_pool_create()
116 pool->is_mmap = MHD_NO; in MHD_pool_create()
120 pool->is_mmap = MHD_YES; in MHD_pool_create()
122 pool->pos = 0; in MHD_pool_create()
123 pool->end = max; in MHD_pool_create()
124 pool->size = max; in MHD_pool_create()
125 return pool; in MHD_pool_create()
135 MHD_pool_destroy (struct MemoryPool *pool) in MHD_pool_destroy() argument
137 if (pool == NULL) in MHD_pool_destroy()
139 if (pool->is_mmap == MHD_NO) in MHD_pool_destroy()
140 free (pool->memory); in MHD_pool_destroy()
143 munmap (pool->memory, pool->size); in MHD_pool_destroy()
145 VirtualFree(pool->memory, 0, MEM_RELEASE); in MHD_pool_destroy()
149 free (pool); in MHD_pool_destroy()
165 MHD_pool_allocate (struct MemoryPool *pool, in MHD_pool_allocate() argument
174 if ((pool->pos + asize > pool->end) || (pool->pos + asize < pool->pos)) in MHD_pool_allocate()
178 ret = &pool->memory[pool->end - asize]; in MHD_pool_allocate()
179 pool->end -= asize; in MHD_pool_allocate()
183 ret = &pool->memory[pool->pos]; in MHD_pool_allocate()
184 pool->pos += asize; in MHD_pool_allocate()
208 MHD_pool_reallocate (struct MemoryPool *pool, in MHD_pool_reallocate() argument
219 if ((pool->end < old_size) || (pool->end < asize)) in MHD_pool_reallocate()
222 if ((pool->pos >= old_size) && (&pool->memory[pool->pos - old_size] == old)) in MHD_pool_reallocate()
225 if (pool->pos + asize - old_size <= pool->end) in MHD_pool_reallocate()
228 pool->pos += asize - old_size; in MHD_pool_reallocate()
230 memset (&pool->memory[pool->pos], 0, old_size - asize); in MHD_pool_reallocate()
238 if ((pool->pos + asize >= pool->pos) && in MHD_pool_reallocate()
239 (pool->pos + asize <= pool->end)) in MHD_pool_reallocate()
242 ret = &pool->memory[pool->pos]; in MHD_pool_reallocate()
244 pool->pos += asize; in MHD_pool_reallocate()
262 MHD_pool_reset (struct MemoryPool *pool, in MHD_pool_reset() argument
268 if (keep != pool->memory) in MHD_pool_reset()
270 memmove (pool->memory, keep, size); in MHD_pool_reset()
271 keep = pool->memory; in MHD_pool_reset()
274 pool->end = pool->size; in MHD_pool_reset()
275 memset (&pool->memory[size], in MHD_pool_reset()
277 pool->size - size); in MHD_pool_reset()
279 pool->pos = ROUND_TO_ALIGN(size); in MHD_pool_reset()