Changeset 1093620 in mainline for generic/src/mm/buddy.c
- Timestamp:
- 2006-01-22T16:51:11Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0d8d27c
- Parents:
- bd6e392
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/mm/buddy.c
rbd6e392 r1093620 69 69 * Allocate memory for all orders this buddy system will work with. 70 70 */ 71 b->order = (link_t *) early_malloc( max_order* sizeof(link_t));71 b->order = (link_t *) early_malloc((max_order + 1) * sizeof(link_t)); 72 72 if (!b->order) { 73 73 early_free(b); … … 75 75 } 76 76 77 for (i = 0; i < max_order; i++)77 for (i = 0; i <= max_order; i++) 78 78 list_initialize(&b->order[i]); 79 79 … … 96 96 __u8 k; 97 97 98 ASSERT(i < b->max_order); 99 100 for (k=i; k < b->max_order; k++) { 98 /* 99 * If requested block is greater then maximal block 100 * we know immediatly that we cannot satisfy the request. 101 */ 102 if (i > b->max_order) return false; 103 104 /* 105 * Check if any bigger or equal order has free elements 106 */ 107 for (k=i; k <= b->max_order; k++) { 101 108 if (!list_empty(&b->order[k])) { 102 109 return true; … … 119 126 link_t *res, *hlp; 120 127 121 ASSERT(i < b->max_order);128 ASSERT(i <= b->max_order); 122 129 123 130 /* … … 136 143 * the request cannot be satisfied. 137 144 */ 138 if (i == b->max_order - 1)145 if (i == b->max_order) 139 146 return NULL; 140 147 … … 186 193 i = b->op->get_order(b, block); 187 194 188 ASSERT(i < b->max_order);189 190 if (i != b->max_order - 1) {195 ASSERT(i <= b->max_order); 196 197 if (i != b->max_order) { 191 198 /* 192 199 * See if there is any buddy in the list of order i. … … 246 253 printf("-----\t------\t--------\t----------\t---------------\n"); 247 254 248 for (i=0;i < b->max_order; i++) {255 for (i=0;i <= b->max_order; i++) { 249 256 cnt = 0; 250 257 if (!list_empty(&b->order[i])) {
Note:
See TracChangeset
for help on using the changeset viewer.