Lines Matching refs:free_block

132 struct free_block {  struct
134 struct free_block *next; argument
135 struct free_block *prev; argument
142 ((struct free_block*)(((sljit_u8*)base) + offset)) argument
146 static struct free_block* free_blocks;
150 static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) in sljit_insert_free_block() argument
152 free_block->header.size = 0; in sljit_insert_free_block()
153 free_block->size = size; in sljit_insert_free_block()
155 free_block->next = free_blocks; in sljit_insert_free_block()
156 free_block->prev = NULL; in sljit_insert_free_block()
158 free_blocks->prev = free_block; in sljit_insert_free_block()
159 free_blocks = free_block; in sljit_insert_free_block()
162 static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block) in sljit_remove_free_block() argument
164 if (free_block->next) in sljit_remove_free_block()
165 free_block->next->prev = free_block->prev; in sljit_remove_free_block()
167 if (free_block->prev) in sljit_remove_free_block()
168 free_block->prev->next = free_block->next; in sljit_remove_free_block()
170 SLJIT_ASSERT(free_blocks == free_block); in sljit_remove_free_block()
171 free_blocks = free_block->next; in sljit_remove_free_block()
179 struct free_block *free_block; in sljit_malloc_exec() local
187 free_block = free_blocks; in sljit_malloc_exec()
188 while (free_block) { in sljit_malloc_exec()
189 if (free_block->size >= size) { in sljit_malloc_exec()
190 chunk_size = free_block->size; in sljit_malloc_exec()
194 free_block->size = chunk_size; in sljit_malloc_exec()
195 header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
200 sljit_remove_free_block(free_block); in sljit_malloc_exec()
201 header = (struct block_header*)free_block; in sljit_malloc_exec()
209 free_block = free_block->next; in sljit_malloc_exec()
229 free_block = AS_FREE_BLOCK(header, size); in sljit_malloc_exec()
230 free_block->header.prev_size = size; in sljit_malloc_exec()
231 sljit_insert_free_block(free_block, chunk_size); in sljit_malloc_exec()
232 next_header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
249 struct free_block* free_block; in sljit_free_exec() local
259 free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_size); in sljit_free_exec()
260 if (SLJIT_UNLIKELY(!free_block->header.size)) { in sljit_free_exec()
261 free_block->size += header->size; in sljit_free_exec()
262 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
263 header->prev_size = free_block->size; in sljit_free_exec()
266 free_block = (struct free_block*)header; in sljit_free_exec()
267 sljit_insert_free_block(free_block, header->size); in sljit_free_exec()
270 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
272 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
273 sljit_remove_free_block((struct free_block*)header); in sljit_free_exec()
274 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
275 header->prev_size = free_block->size; in sljit_free_exec()
279 if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) { in sljit_free_exec()
281 if (total_size - free_block->size > (allocated_size * 3 / 2)) { in sljit_free_exec()
282 total_size -= free_block->size; in sljit_free_exec()
283 sljit_remove_free_block(free_block); in sljit_free_exec()
284 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_exec()
293 struct free_block* free_block; in sljit_free_unused_memory_exec() local
294 struct free_block* next_free_block; in sljit_free_unused_memory_exec()
298 free_block = free_blocks; in sljit_free_unused_memory_exec()
299 while (free_block) { in sljit_free_unused_memory_exec()
300 next_free_block = free_block->next; in sljit_free_unused_memory_exec()
301 if (!free_block->header.prev_size && in sljit_free_unused_memory_exec()
302 AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) { in sljit_free_unused_memory_exec()
303 total_size -= free_block->size; in sljit_free_unused_memory_exec()
304 sljit_remove_free_block(free_block); in sljit_free_unused_memory_exec()
305 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_unused_memory_exec()
307 free_block = next_free_block; in sljit_free_unused_memory_exec()