Rev 4606 | Rev 4642 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4606 | Rev 4607 | ||
---|---|---|---|
Line 278... | Line 278... | ||
278 | } else { |
278 | } else { |
279 | /* Block start has to be aligned */ |
279 | /* Block start has to be aligned */ |
280 | size_t excess = (size_t) (aligned - addr); |
280 | size_t excess = (size_t) (aligned - addr); |
281 | 281 | ||
282 | if (cur->size >= real_size + excess) { |
282 | if (cur->size >= real_size + excess) { |
283 | /* The current block is large enought to fit |
283 | /* The current block is large enough to fit |
284 | data in including alignment */ |
284 | data in including alignment */ |
285 | if ((void *) cur > heap_start) { |
285 | if ((void *) cur > heap_start) { |
286 | /* There is a block before the current block. |
286 | /* There is a block before the current block. |
287 | This previous block can be enlarged to compensate |
287 | This previous block can be enlarged to compensate |
288 | for the alignment excess */ |
288 | for the alignment excess */ |
Line 296... | Line 296... | ||
296 | 296 | ||
297 | size_t reduced_size = cur->size - excess; |
297 | size_t reduced_size = cur->size - excess; |
298 | heap_block_head_t *next_head = ((void *) cur) + excess; |
298 | heap_block_head_t *next_head = ((void *) cur) + excess; |
299 | 299 | ||
300 | if ((!prev_head->free) && (excess >= STRUCT_OVERHEAD)) { |
300 | if ((!prev_head->free) && (excess >= STRUCT_OVERHEAD)) { |
301 | /* The previous block is not free and there is enought |
301 | /* The previous block is not free and there is enough |
302 | space to fill in a new free block between the previous |
302 | space to fill in a new free block between the previous |
303 | and current block */ |
303 | and current block */ |
304 | block_init(cur, excess, true); |
304 | block_init(cur, excess, true); |
305 | } else { |
305 | } else { |
306 | /* The previous block is free (thus there is no need to |
306 | /* The previous block is free (thus there is no need to |
Line 314... | Line 314... | ||
314 | result = aligned; |
314 | result = aligned; |
315 | cur = next_head; |
315 | cur = next_head; |
316 | } else { |
316 | } else { |
317 | /* The current block is the first block on the heap. |
317 | /* The current block is the first block on the heap. |
318 | We have to make sure that the alignment excess |
318 | We have to make sure that the alignment excess |
319 | is large enought to fit a new free block just |
319 | is large enough to fit a new free block just |
320 | before the current block */ |
320 | before the current block */ |
321 | while (excess < STRUCT_OVERHEAD) { |
321 | while (excess < STRUCT_OVERHEAD) { |
322 | aligned += falign; |
322 | aligned += falign; |
323 | excess += falign; |
323 | excess += falign; |
324 | } |
324 | } |