Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset da287d1 in mainline


Ignore:
Timestamp:
2012-07-23T16:20:56Z (8 years ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
c828803
Parents:
b078a42
Message:

cstyle (no change in functionality)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/malloc.c

    rb078a42 rda287d1  
    110110
    111111#define AREA_LAST_BLOCK_HEAD(area) \
    112         ((uintptr_t) BLOCK_HEAD(((heap_block_foot_t *)AREA_LAST_BLOCK_FOOT(area))))
     112        ((uintptr_t) BLOCK_HEAD(((heap_block_foot_t *) AREA_LAST_BLOCK_FOOT(area))))
    113113
    114114/** Get header in heap block.
     
    349349                return false;
    350350       
    351         heap_block_head_t *last_head = (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area);
     351        heap_block_head_t *last_head =
     352            (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area);
    352353       
    353354        if (last_head->free) {
     
    651652
    652653/** Try to enlarge any of the heap areas.
    653  *  If successful, allocate block of the given size in the area.
    654  *
     654 *
     655 * If successful, allocate block of the given size in the area.
    655656 * Should be called only inside the critical section.
    656657 *
    657  * @param size Gross size of item to allocate (bytes).
     658 * @param size  Gross size of item to allocate (bytes).
    658659 * @param align Memory address alignment.
     660 *
     661 * @return Allocated block.
     662 * @return NULL on failure.
    659663 *
    660664 */
     
    663667        if (size == 0)
    664668                return NULL;
    665                
     669       
    666670        /* First try to enlarge some existing area */
    667671        for (heap_area_t *area = first_heap_area; area != NULL;
    668672            area = area->next) {
    669            
     673               
    670674                if (area_grow(area, size + align)) {
    671                         heap_block_head_t *first = (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area);
    672                        
    673                         void *addr = malloc_area(area, first, NULL, size, align);
     675                        heap_block_head_t *first =
     676                            (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area);
     677                       
     678                        void *addr =
     679                            malloc_area(area, first, NULL, size, align);
    674680                        malloc_assert(addr != NULL);
    675681                        return addr;
     
    679685        /* Eventually try to create a new area */
    680686        if (area_create(AREA_OVERHEAD(size + align))) {
    681                 heap_block_head_t *first = (heap_block_head_t *) AREA_FIRST_BLOCK_HEAD(last_heap_area);
    682                
    683                 void *addr = malloc_area(last_heap_area, first, NULL, size, align);
     687                heap_block_head_t *first =
     688                    (heap_block_head_t *) AREA_FIRST_BLOCK_HEAD(last_heap_area);
     689               
     690                void *addr =
     691                    malloc_area(last_heap_area, first, NULL, size, align);
    684692                malloc_assert(addr != NULL);
    685693                return addr;
     
    707715       
    708716        size_t falign = lcm(align, BASE_ALIGN);
    709 
     717       
    710718        /* Check for integer overflow. */
    711719        if (falign < align)
    712720                return NULL;
    713 
     721       
    714722        size_t gross_size = GROSS_SIZE(ALIGN_UP(size, BASE_ALIGN));
    715723       
    716         heap_block_head_t *split;
    717        
    718724        /* Try the next fit approach */
    719         split = next_fit;
     725        heap_block_head_t *split = next_fit;
    720726       
    721727        if (split != NULL) {
Note: See TracChangeset for help on using the changeset viewer.