Lines Matching refs:reg
75 static void region_list_remove(struct region_list *list, struct region *reg)
77 if (reg->prev)
78 reg->prev->next = reg->next;
80 if (reg->next)
81 reg->next->prev = reg->prev;
83 if (list->first == reg)
84 list->first = reg->next;
86 if (list->last == reg)
87 list->last = reg->prev;
89 reg->next = NULL;
90 reg->prev = NULL;
93 static void region_list_append(struct region_list *list, struct region *reg)
96 list->first = reg;
97 list->last = reg;
98 list->iter = reg;
100 reg->prev = NULL;
102 list->last->next = reg;
103 reg->prev = list->last;
104 list->last = reg;
106 reg->next = NULL;
110 static void dump_starting_from(struct region *reg)
112 for (; reg; reg = reg->next) {
113 printf("%p: Blocks %d-%d (%d)\n", reg,
114 reg->bg * info.blocks_per_group + reg->block,
115 reg->bg * info.blocks_per_group + reg->block + reg->len - 1,
116 reg->len);
133 struct region *reg;
134 reg = malloc(sizeof(struct region));
135 reg->block = block;
136 reg->len = len;
137 reg->bg = bg_num;
138 reg->next = NULL;
140 region_list_append(&alloc->list, reg);
255 struct region *reg = alloc->list.last->prev;
258 if (reg) {
259 reg->next = NULL;
349 struct region *reg;
355 reg = malloc(sizeof(struct region));
356 reg->block = block;
357 reg->len = len;
358 reg->next = NULL;
359 reg->prev = NULL;
360 reg->bg = i;
361 return reg;
385 struct region *reg;
397 reg = ext4_allocate_contiguous_blocks(len);
406 reg = malloc(sizeof(struct region));
407 reg->block = block;
408 reg->len = bg_len;
409 reg->next = NULL;
410 reg->prev = NULL;
411 reg->bg = i;
414 return reg;
424 struct region *reg;
427 reg = ext4_allocate_partial(len);
428 if (reg == NULL)
432 first_reg = reg;
435 prev_reg->next = reg;
436 reg->prev = prev_reg;
439 prev_reg = reg;
440 len -= reg->len;
448 struct region *reg = ext4_allocate_contiguous_blocks(len);
450 if (reg == NULL)
451 reg = ext4_allocate_multiple_contiguous_blocks(len);
453 return reg;
466 struct region *reg = do_allocate(len);
468 if (reg == NULL)
472 alloc->list.first = reg;
473 alloc->list.last = reg;
483 struct region *reg = alloc->list.first;
485 for (i = 0; reg != NULL; reg = reg->next)
494 struct region *reg = alloc->list.first;
496 for (i = 0; reg != NULL; reg = reg->next)
497 i += reg->len;
505 struct region *reg = alloc->list.iter;
508 for (; reg; reg = reg->next) {
509 if (block < reg->len)
510 return reg->block + block;
511 block -= reg->len;
518 struct region *reg = alloc->oob_list.iter;
521 for (; reg; reg = reg->next) {
522 if (block < reg->len)
523 return reg->block + block;
524 block -= reg->len;
563 struct region *reg = alloc->list.iter;
567 while (reg && len >= reg->len) {
568 len -= reg->len;
569 reg = reg->next;
572 if (reg == NULL && len > 0)
578 new->bg = reg->bg;
579 new->block = reg->block + len;
580 new->len = reg->len - len;
581 new->next = reg->next;
582 new->prev = reg;
584 reg->next = new;
585 reg->len = len;
591 return reg;
630 struct region *reg = list->iter;
632 while (reg != NULL && blocks > 0) {
633 if (reg->len > list->partial_iter + blocks) {
638 blocks -= (reg->len - list->partial_iter);
640 reg = reg->next;
662 struct region *reg = do_allocate(len);
664 if (reg == NULL) {
669 for (; reg; reg = reg->next)
670 region_list_append(&alloc->oob_list, reg);
747 struct region *reg;
749 reg = alloc->list.first;
750 while (reg) {
751 struct region *next = reg->next;
752 free(reg);
753 reg = next;
756 reg = alloc->oob_list.first;
757 while (reg) {
758 struct region *next = reg->next;
759 free(reg);
760 reg = next;