Rev 4607 | Rev 4643 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4607 | Rev 4642 | ||
---|---|---|---|
Line 382... | Line 382... | ||
382 | 382 | ||
383 | block_check(head); |
383 | block_check(head); |
384 | assert(!head->free); |
384 | assert(!head->free); |
385 | 385 | ||
386 | void *ptr = NULL; |
386 | void *ptr = NULL; |
387 | size_t real_size = GROSS_SIZE(size); |
387 | size_t real_size = GROSS_SIZE(ALIGN_UP(size, BASE_ALIGN)); |
388 | size_t orig_size = head->size; |
388 | size_t orig_size = head->size; |
389 | 389 | ||
390 | if (orig_size > real_size) { |
390 | if (orig_size > real_size) { |
391 | /* Shrink */ |
391 | /* Shrink */ |
392 | if (orig_size - real_size >= STRUCT_OVERHEAD) { |
392 | if (orig_size - real_size >= STRUCT_OVERHEAD) { |
Line 407... | Line 407... | ||
407 | 407 | ||
408 | if (((void *) next_head < heap_end) |
408 | if (((void *) next_head < heap_end) |
409 | && (head->size + next_head->size >= real_size)) { |
409 | && (head->size + next_head->size >= real_size)) { |
410 | block_check(next_head); |
410 | block_check(next_head); |
411 | block_init(head, head->size + next_head->size, false); |
411 | block_init(head, head->size + next_head->size, false); |
412 | split_mark(head, size); |
412 | split_mark(head, ALIGN_UP(size, BASE_ALIGN)); |
413 | 413 | ||
414 | ptr = ((void *) head) + sizeof(heap_block_head_t); |
414 | ptr = ((void *) head) + sizeof(heap_block_head_t); |
415 | } else { |
415 | } else { |
416 | ptr = malloc(size); |
416 | ptr = malloc(size); |
417 | if (ptr != NULL) { |
417 | if (ptr != NULL) { |