Lines Matching defs:alloc

70 	struct block_allocation *alloc = malloc(sizeof(struct block_allocation));
71 alloc->list.first = NULL;
72 alloc->list.last = NULL;
73 alloc->oob_list.first = NULL;
74 alloc->oob_list.last = NULL;
75 alloc->list.iter = NULL;
76 alloc->list.partial_iter = 0;
77 alloc->oob_list.iter = NULL;
78 alloc->oob_list.partial_iter = 0;
79 return alloc;
146 static void dump_region_lists(struct block_allocation *alloc) {
149 dump_starting_from(alloc->list.first);
152 dump_starting_from(alloc->oob_list.first);
156 void append_region(struct block_allocation *alloc,
166 region_list_append(&alloc->list, reg);
256 void reduce_allocation(struct block_allocation *alloc, u32 len)
259 struct region *last_reg = alloc->list.last;
266 struct region *reg = alloc->list.last->prev;
272 alloc->list.first = NULL;
273 alloc->list.last = NULL;
274 alloc->list.iter = NULL;
275 alloc->list.partial_iter = 0;
452 struct block_allocation *alloc = create_allocation();
453 alloc->list.first = reg;
454 alloc->list.last = reg;
455 alloc->list.iter = alloc->list.first;
456 alloc->list.partial_iter = 0;
457 return alloc;
461 int block_allocation_num_regions(struct block_allocation *alloc)
464 struct region *reg = alloc->list.first;
472 int block_allocation_len(struct block_allocation *alloc)
475 struct region *reg = alloc->list.first;
484 u32 get_block(struct block_allocation *alloc, u32 block)
486 struct region *reg = alloc->list.iter;
487 block += alloc->list.partial_iter;
497 u32 get_oob_block(struct block_allocation *alloc, u32 block)
499 struct region *reg = alloc->oob_list.iter;
500 block += alloc->oob_list.partial_iter;
512 void get_region(struct block_allocation *alloc, u32 *block, u32 *len)
514 *block = alloc->list.iter->block;
515 *len = alloc->list.iter->len - alloc->list.partial_iter;
519 void get_next_region(struct block_allocation *alloc)
521 alloc->list.iter = alloc->list.iter->next;
522 alloc->list.partial_iter = 0;
531 int last_region(struct block_allocation *alloc)
533 return (alloc->list.iter == NULL);
536 void rewind_alloc(struct block_allocation *alloc)
538 alloc->list.iter = alloc->list.first;
539 alloc->list.partial_iter = 0;
542 static struct region *do_split_allocation(struct block_allocation *alloc, u32 len)
544 struct region *reg = alloc->list.iter;
568 tmp = alloc->list.iter;
569 alloc->list.iter = new;
579 static struct region *split_allocation(struct block_allocation *alloc, u32 len)
582 do_split_allocation(alloc, alloc->list.partial_iter);
585 struct region *middle = do_split_allocation(alloc, len);
586 alloc->list.partial_iter = 0;
591 int reserve_oob_blocks(struct block_allocation *alloc, int blocks)
593 struct region *oob = split_allocation(alloc, blocks);
599 while (oob && oob != alloc->list.iter) {
601 region_list_remove(&alloc->list, oob);
602 region_list_append(&alloc->oob_list, oob);
631 int advance_blocks(struct block_allocation *alloc, int blocks)
633 return advance_list_ptr(&alloc->list, blocks);
636 int advance_oob_blocks(struct block_allocation *alloc, int blocks)
638 return advance_list_ptr(&alloc->oob_list, blocks);
641 int append_oob_allocation(struct block_allocation *alloc, u32 len)
651 region_list_append(&alloc->oob_list, reg);
761 void free_alloc(struct block_allocation *alloc)
765 reg = alloc->list.first;
772 reg = alloc->oob_list.first;
779 free(alloc);