Changes in uspace/lib/c/generic/malloc.c [3019612:13f2461] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
r3019612 r13f2461 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 85 81 /** Calculate real size of a heap block. 86 82 * … … 187 183 188 184 /** Next heap block to examine (next fit algorithm) */ 189 static heap_block_head_t *next _fit= NULL;185 static heap_block_head_t *next = NULL; 190 186 191 187 /** Futex for thread-safe heap manipulation */ … … 198 194 if (!(expr)) {\ 199 195 futex_up(&malloc_futex); \ 200 assert_abort(#expr, __FILE__, __LINE__); \196 assert_abort(#expr, __FILE__, STR2(__LINE__)); \ 201 197 } \ 202 198 } while (0) … … 382 378 383 379 /* Eventually try to create a new area */ 384 return area_create(AREA_ OVERHEAD(size));380 return area_create(AREA_FIRST_BLOCK_HEAD(size)); 385 381 } 386 382 … … 459 455 /* Update heap area parameters */ 460 456 area->end = end; 461 size_t excess = ((size_t) area->end) - ((size_t) last_head); 457 458 /* Update block layout */ 459 void *last = (void *) last_head; 460 size_t excess = (size_t) (area->end - last); 462 461 463 462 if (excess > 0) { … … 468 467 * create a new free block. 469 468 */ 470 block_init( (void *) last_head, excess, true, area);469 block_init(last, excess, true, area); 471 470 } else { 472 471 /* … … 487 486 } 488 487 489 next _fit= NULL;488 next = NULL; 490 489 } 491 490 … … 576 575 split_mark(cur, real_size); 577 576 578 next _fit= cur;577 next = cur; 579 578 return addr; 580 579 } else { … … 628 627 split_mark(next_head, real_size); 629 628 630 next _fit= next_head;629 next = next_head; 631 630 return aligned; 632 631 } else { … … 654 653 split_mark(cur, real_size); 655 654 656 next _fit= cur;655 next = cur; 657 656 return aligned; 658 657 } … … 692 691 693 692 /* Try the next fit approach */ 694 split = next _fit;693 split = next; 695 694 696 695 if (split != NULL) { … … 848 847 849 848 ptr = ((void *) head) + sizeof(heap_block_head_t); 850 next _fit= NULL;849 next = NULL; 851 850 } else 852 851 reloc = true; … … 873 872 void free(const void *addr) 874 873 { 875 if (addr == NULL)876 return;877 878 874 futex_down(&malloc_futex); 879 875
Note:
See TracChangeset
for help on using the changeset viewer.