Lines Matching refs:free_block
226 struct free_block { struct
228 struct free_block *next; argument
229 struct free_block *prev; argument
236 ((struct free_block*)(((sljit_u8*)base) + offset)) argument
240 static struct free_block* free_blocks;
244 static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) in sljit_insert_free_block() argument
246 free_block->header.size = 0; in sljit_insert_free_block()
247 free_block->size = size; in sljit_insert_free_block()
249 free_block->next = free_blocks; in sljit_insert_free_block()
250 free_block->prev = NULL; in sljit_insert_free_block()
252 free_blocks->prev = free_block; in sljit_insert_free_block()
253 free_blocks = free_block; in sljit_insert_free_block()
256 static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block) in sljit_remove_free_block() argument
258 if (free_block->next) in sljit_remove_free_block()
259 free_block->next->prev = free_block->prev; in sljit_remove_free_block()
261 if (free_block->prev) in sljit_remove_free_block()
262 free_block->prev->next = free_block->next; in sljit_remove_free_block()
264 SLJIT_ASSERT(free_blocks == free_block); in sljit_remove_free_block()
265 free_blocks = free_block->next; in sljit_remove_free_block()
273 struct free_block *free_block; in sljit_malloc_exec() local
281 free_block = free_blocks; in sljit_malloc_exec()
282 while (free_block) { in sljit_malloc_exec()
283 if (free_block->size >= size) { in sljit_malloc_exec()
284 chunk_size = free_block->size; in sljit_malloc_exec()
289 free_block->size = chunk_size; in sljit_malloc_exec()
290 header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
295 sljit_remove_free_block(free_block); in sljit_malloc_exec()
296 header = (struct block_header*)free_block; in sljit_malloc_exec()
304 free_block = free_block->next; in sljit_malloc_exec()
324 free_block = AS_FREE_BLOCK(header, size); in sljit_malloc_exec()
325 free_block->header.prev_size = size; in sljit_malloc_exec()
326 sljit_insert_free_block(free_block, chunk_size); in sljit_malloc_exec()
327 next_header = AS_BLOCK_HEADER(free_block, chunk_size); in sljit_malloc_exec()
344 struct free_block* free_block; in sljit_free_exec() local
355 free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_size); in sljit_free_exec()
356 if (SLJIT_UNLIKELY(!free_block->header.size)) { in sljit_free_exec()
357 free_block->size += header->size; in sljit_free_exec()
358 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
359 header->prev_size = free_block->size; in sljit_free_exec()
362 free_block = (struct free_block*)header; in sljit_free_exec()
363 sljit_insert_free_block(free_block, header->size); in sljit_free_exec()
366 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
368 free_block->size += ((struct free_block*)header)->size; in sljit_free_exec()
369 sljit_remove_free_block((struct free_block*)header); in sljit_free_exec()
370 header = AS_BLOCK_HEADER(free_block, free_block->size); in sljit_free_exec()
371 header->prev_size = free_block->size; in sljit_free_exec()
375 if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) { in sljit_free_exec()
377 if (total_size - free_block->size > (allocated_size * 3 / 2)) { in sljit_free_exec()
378 total_size -= free_block->size; in sljit_free_exec()
379 sljit_remove_free_block(free_block); in sljit_free_exec()
380 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_exec()
390 struct free_block* free_block; in sljit_free_unused_memory_exec() local
391 struct free_block* next_free_block; in sljit_free_unused_memory_exec()
396 free_block = free_blocks; in sljit_free_unused_memory_exec()
397 while (free_block) { in sljit_free_unused_memory_exec()
398 next_free_block = free_block->next; in sljit_free_unused_memory_exec()
399 if (!free_block->header.prev_size && in sljit_free_unused_memory_exec()
400 AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) { in sljit_free_unused_memory_exec()
401 total_size -= free_block->size; in sljit_free_unused_memory_exec()
402 sljit_remove_free_block(free_block); in sljit_free_unused_memory_exec()
403 free_chunk(free_block, free_block->size + sizeof(struct block_header)); in sljit_free_unused_memory_exec()
405 free_block = next_free_block; in sljit_free_unused_memory_exec()