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