Lines Matching refs:free_block
139 struct free_block { struct
141 struct free_block *next; argument
142 struct free_block *prev; argument
149 ((struct free_block*)(((sljit_u8*)base) + offset)) argument
153 static struct free_block* free_blocks;
157 static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) in sljit_insert_free_block() argument
159 free_block->header.size = 0; in sljit_insert_free_block()
160 free_block->size = size; in sljit_insert_free_block()
162 free_block->next = free_blocks; in sljit_insert_free_block()
163 free_block->prev = NULL; in sljit_insert_free_block()
165 free_blocks->prev = free_block; in sljit_insert_free_block()
166 free_blocks = free_block; in sljit_insert_free_block()
169 static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block) in sljit_remove_free_block() argument
171 if (free_block->next) in sljit_remove_free_block()
172 free_block->next->prev = free_block->prev; in sljit_remove_free_block()
174 if (free_block->prev) in sljit_remove_free_block()
175 free_block->prev->next = free_block->next; in sljit_remove_free_block()
177 SLJIT_ASSERT(free_blocks == free_block); in sljit_remove_free_block()
178 free_blocks = free_block->next; in sljit_remove_free_block()
186 struct free_block *free_block; in sljit_malloc_exec() local
194 free_block = free_blocks; in sljit_malloc_exec()
195 while (free_block) { in sljit_malloc_exec()
196 if (free_block->size >= size) { in sljit_malloc_exec()
197 chunk_size = free_block->size; in sljit_malloc_exec()
201 free_block->size = chunk_size; in sljit_malloc_exec()
202 header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
207 sljit_remove_free_block(free_block); in sljit_malloc_exec()
208 header = (struct block_header*)free_block; in sljit_malloc_exec()
216 free_block = free_block->next; in sljit_malloc_exec()
236 free_block = AS_FREE_BLOCK(header, size); in sljit_malloc_exec()
237 free_block->header.prev_size = size; in sljit_malloc_exec()
238 sljit_insert_free_block(free_block, chunk_size); in sljit_malloc_exec()
239 next_header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
256 struct free_block* free_block; in sljit_free_exec() local
266 free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_size); in sljit_free_exec()
267 if (SLJIT_UNLIKELY(!free_block->header.size)) { in sljit_free_exec()
268 free_block->size += header->size; in sljit_free_exec()
269 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
270 header->prev_size = free_block->size; in sljit_free_exec()
273 free_block = (struct free_block*)header; in sljit_free_exec()
274 sljit_insert_free_block(free_block, header->size); in sljit_free_exec()
277 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
279 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
280 sljit_remove_free_block((struct free_block*)header); in sljit_free_exec()
281 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
282 header->prev_size = free_block->size; in sljit_free_exec()
286 if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) { in sljit_free_exec()
288 if (total_size - free_block->size > (allocated_size * 3 / 2)) { in sljit_free_exec()
289 total_size -= free_block->size; in sljit_free_exec()
290 sljit_remove_free_block(free_block); in sljit_free_exec()
291 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_exec()
300 struct free_block* free_block; in sljit_free_unused_memory_exec() local
301 struct free_block* next_free_block; in sljit_free_unused_memory_exec()
305 free_block = free_blocks; in sljit_free_unused_memory_exec()
306 while (free_block) { in sljit_free_unused_memory_exec()
307 next_free_block = free_block->next; in sljit_free_unused_memory_exec()
308 if (!free_block->header.prev_size && in sljit_free_unused_memory_exec()
309 AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) { in sljit_free_unused_memory_exec()
310 total_size -= free_block->size; in sljit_free_unused_memory_exec()
311 sljit_remove_free_block(free_block); in sljit_free_unused_memory_exec()
312 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_unused_memory_exec()
314 free_block = next_free_block; in sljit_free_unused_memory_exec()