Changeset 207533f in mainline
- Timestamp:
- 2011-05-23T13:31:10Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d8de5d3
- Parents:
- 34efa8a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
r34efa8a r207533f 79 79 (sizeof(heap_block_head_t) + sizeof(heap_block_foot_t)) 80 80 81 /** Overhead of each area. */ 82 #define AREA_OVERHEAD(size) \ 83 (ALIGN_UP(size + sizeof(heap_area_t), BASE_ALIGN)) 84 81 85 /** Calculate real size of a heap block. 82 86 * … … 183 187 184 188 /** Next heap block to examine (next fit algorithm) */ 185 static heap_block_head_t *next = NULL;189 static heap_block_head_t *next_fit = NULL; 186 190 187 191 /** Futex for thread-safe heap manipulation */ … … 378 382 379 383 /* Eventually try to create a new area */ 380 return area_create(AREA_ FIRST_BLOCK_HEAD(size));384 return area_create(AREA_OVERHEAD(size)); 381 385 } 382 386 … … 455 459 /* Update heap area parameters */ 456 460 area->end = end; 457 458 /* Update block layout */ 459 void *last = (void *) last_head; 460 size_t excess = (size_t) (area->end - last); 461 size_t excess = ((size_t) area->end) - ((size_t) last_head); 461 462 462 463 if (excess > 0) { … … 467 468 * create a new free block. 468 469 */ 469 block_init( last, excess, true, area);470 block_init((void *) last_head, excess, true, area); 470 471 } else { 471 472 /* … … 486 487 } 487 488 488 next = NULL;489 next_fit = NULL; 489 490 } 490 491 … … 575 576 split_mark(cur, real_size); 576 577 577 next = cur;578 next_fit = cur; 578 579 return addr; 579 580 } else { … … 627 628 split_mark(next_head, real_size); 628 629 629 next = next_head;630 next_fit = next_head; 630 631 return aligned; 631 632 } else { … … 653 654 split_mark(cur, real_size); 654 655 655 next = cur;656 next_fit = cur; 656 657 return aligned; 657 658 } … … 691 692 692 693 /* Try the next fit approach */ 693 split = next ;694 split = next_fit; 694 695 695 696 if (split != NULL) { … … 847 848 848 849 ptr = ((void *) head) + sizeof(heap_block_head_t); 849 next = NULL;850 next_fit = NULL; 850 851 } else 851 852 reloc = true;
Note:
See TracChangeset
for help on using the changeset viewer.