Lines Matching refs:alloc
33 struct block_allocation *alloc = malloc(sizeof(struct block_allocation)); in create_allocation() local
34 alloc->list.first = NULL; in create_allocation()
35 alloc->list.last = NULL; in create_allocation()
36 alloc->oob_list.first = NULL; in create_allocation()
37 alloc->oob_list.last = NULL; in create_allocation()
38 alloc->list.iter = NULL; in create_allocation()
39 alloc->list.partial_iter = 0; in create_allocation()
40 alloc->oob_list.iter = NULL; in create_allocation()
41 alloc->oob_list.partial_iter = 0; in create_allocation()
42 alloc->filename = NULL; in create_allocation()
43 alloc->next = NULL; in create_allocation()
44 return alloc; in create_allocation()
123 static void dump_region_lists(struct block_allocation *alloc) {
126 dump_starting_from(alloc->list.first);
129 dump_starting_from(alloc->oob_list.first);
133 void print_blocks(FILE* f, struct block_allocation *alloc, char separator) in print_blocks() argument
137 for (reg = alloc->list.first; reg; reg = reg->next) { in print_blocks()
148 void append_region(struct block_allocation *alloc, in append_region() argument
158 region_list_append(&alloc->list, reg); in append_region()
241 void reduce_allocation(struct block_allocation *alloc, u32 len) in reduce_allocation() argument
244 struct region *last_reg = alloc->list.last; in reduce_allocation()
252 struct region *reg = alloc->list.last->prev; in reduce_allocation()
258 alloc->list.first = NULL; in reduce_allocation()
259 alloc->list.last = NULL; in reduce_allocation()
260 alloc->list.iter = NULL; in reduce_allocation()
261 alloc->list.partial_iter = 0; in reduce_allocation()
455 struct block_allocation *alloc = create_allocation(); in allocate_blocks() local
456 alloc->list.first = reg; in allocate_blocks()
459 alloc->list.last = reg; in allocate_blocks()
460 alloc->list.iter = alloc->list.first; in allocate_blocks()
461 alloc->list.partial_iter = 0; in allocate_blocks()
462 return alloc; in allocate_blocks()
466 int block_allocation_num_regions(struct block_allocation *alloc) in block_allocation_num_regions() argument
469 struct region *reg = alloc->list.first; in block_allocation_num_regions()
477 int block_allocation_len(struct block_allocation *alloc) in block_allocation_len() argument
480 struct region *reg = alloc->list.first; in block_allocation_len()
489 u32 get_block(struct block_allocation *alloc, u32 block) in get_block() argument
491 struct region *reg = alloc->list.iter; in get_block()
492 block += alloc->list.partial_iter; in get_block()
502 u32 get_oob_block(struct block_allocation *alloc, u32 block) in get_oob_block() argument
504 struct region *reg = alloc->oob_list.iter; in get_oob_block()
505 block += alloc->oob_list.partial_iter; in get_oob_block()
517 void get_region(struct block_allocation *alloc, u32 *block, u32 *len) in get_region() argument
519 *block = alloc->list.iter->block; in get_region()
520 *len = alloc->list.iter->len - alloc->list.partial_iter; in get_region()
524 void get_next_region(struct block_allocation *alloc) in get_next_region() argument
526 alloc->list.iter = alloc->list.iter->next; in get_next_region()
527 alloc->list.partial_iter = 0; in get_next_region()
536 int last_region(struct block_allocation *alloc) in last_region() argument
538 return (alloc->list.iter == NULL); in last_region()
541 void rewind_alloc(struct block_allocation *alloc) in rewind_alloc() argument
543 alloc->list.iter = alloc->list.first; in rewind_alloc()
544 alloc->list.partial_iter = 0; in rewind_alloc()
547 static struct region *do_split_allocation(struct block_allocation *alloc, u32 len) in do_split_allocation() argument
549 struct region *reg = alloc->list.iter; in do_split_allocation()
573 tmp = alloc->list.iter; in do_split_allocation()
574 alloc->list.iter = new; in do_split_allocation()
584 static struct region *split_allocation(struct block_allocation *alloc, u32 len) in split_allocation() argument
587 do_split_allocation(alloc, alloc->list.partial_iter); in split_allocation()
590 struct region *middle = do_split_allocation(alloc, len); in split_allocation()
591 alloc->list.partial_iter = 0; in split_allocation()
596 int reserve_oob_blocks(struct block_allocation *alloc, int blocks) in reserve_oob_blocks() argument
598 struct region *oob = split_allocation(alloc, blocks); in reserve_oob_blocks()
604 while (oob && oob != alloc->list.iter) { in reserve_oob_blocks()
606 region_list_remove(&alloc->list, oob); in reserve_oob_blocks()
607 region_list_append(&alloc->oob_list, oob); in reserve_oob_blocks()
636 int advance_blocks(struct block_allocation *alloc, int blocks) in advance_blocks() argument
638 return advance_list_ptr(&alloc->list, blocks); in advance_blocks()
641 int advance_oob_blocks(struct block_allocation *alloc, int blocks) in advance_oob_blocks() argument
643 return advance_list_ptr(&alloc->oob_list, blocks); in advance_oob_blocks()
646 int append_oob_allocation(struct block_allocation *alloc, u32 len) in append_oob_allocation() argument
656 region_list_append(&alloc->oob_list, reg); in append_oob_allocation()
766 void free_alloc(struct block_allocation *alloc) in free_alloc() argument
770 reg = alloc->list.first; in free_alloc()
777 reg = alloc->oob_list.first; in free_alloc()
784 free(alloc); in free_alloc()
803 int reserve_blocks_for_allocation(struct block_allocation *alloc) { in reserve_blocks_for_allocation() argument
807 if (!alloc) return 0; in reserve_blocks_for_allocation()
808 reg = alloc->list.first; in reserve_blocks_for_allocation()