Ticket #1920: heap_large_alloc.diff
File heap_large_alloc.diff, 1.2 KB (added by , 16 years ago) |
---|
-
src/system/kernel/heap.cpp
59 59 } heap_page; 60 60 61 61 // used for bin == bin_count allocations 62 #define allocation_id free_count62 #define allocation_id empty_index 63 63 64 64 typedef struct heap_bin_s { 65 65 uint32 element_size; … … 71 71 addr_t base; 72 72 size_t size; 73 73 mutex lock; 74 vint32 large_alloc_id;75 74 76 75 uint32 bin_count; 77 76 uint32 page_count; … … 536 535 } 537 536 538 537 539 static inline uint32540 heap_next_alloc_id(heap_allocator *heap)541 {542 return atomic_add(&heap->large_alloc_id, 1) & ((1 << 9) - 1);543 }544 545 546 538 static inline void 547 539 heap_link_page(heap_page *page, heap_page **list) 548 540 { … … 672 664 return NULL; 673 665 } 674 666 675 uint32 allocationID = heap_next_alloc_id(heap);676 667 uint32 pageCount = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE; 677 668 for (uint32 i = first; i < first + pageCount; i++) { 678 669 heap_page *page = &heap->page_table[i]; … … 683 674 684 675 page->next = page->prev = NULL; 685 676 page->free_list = NULL; 686 page->allocation_id = allocationID;677 page->allocation_id = (uint16)first; 687 678 } 688 679 689 680 #if KERNEL_HEAP_LEAK_CHECK