Changeset 74f4eda in rtems


Ignore:
Timestamp:
Aug 5, 2009, 3:35:55 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
2b3692d3
Parents:
a2fa532d
Message:

2009-08-05 Joel Sherrill <joel.sherrill@…>

  • score/src/heapallocatealigned.c: Fix spacing.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    ra2fa532d r74f4eda  
     12009-08-05      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * score/src/heapallocatealigned.c: Fix spacing.
     4
    152009-08-05      Joel Sherrill <joel.sherrill@OARcorp.com>
    26
  • cpukit/score/src/heapallocatealigned.c

    ra2fa532d r74f4eda  
    8787  _HAssert(_Heap_Is_prev_used(the_block));
    8888
    89   if(the_rest >= the_heap->min_block_size) {
     89  if (the_rest >= the_heap->min_block_size) {
    9090    /* Split the block so that lower part is still free, and upper part
    9191       becomes used. */
     
    9494    the_block->prev_size = the_rest;
    9595    the_block->size = alloc_size;
    96   }
    97   else {
     96  } else {
    9897    /* Don't split the block as remainder is either zero or too small to be
    9998       used as a separate free block. Change 'alloc_size' to the size of the
     
    107106  /* Update statistics */
    108107  stats->free_size -= alloc_size;
    109   if(stats->min_free_size > stats->free_size)
     108  if (stats->min_free_size > stats->free_size)
    110109    stats->min_free_size = stats->free_size;
    111110  stats->used_blocks += 1;
     
    151150    _Heap_Calc_block_size(size, page_size, the_heap->min_block_size);
    152151
    153   if(the_size == 0)
     152  if (the_size == 0)
    154153    return NULL;
    155154
    156   if(alignment == 0)
     155  if (alignment == 0)
    157156    alignment = CPU_ALIGNMENT;
    158157
    159158  /* Find large enough free block that satisfies the alignment requirements. */
    160159
    161   for(the_block = _Heap_First(the_heap), search_count = 0;
     160  for (the_block = _Heap_First(the_heap), search_count = 0;
    162161      the_block != tail;
    163162      the_block = the_block->next, ++search_count)
     
    168167    _HAssert(_Heap_Is_prev_used(the_block));
    169168
    170     if(block_size >= the_size) { /* the_block is large enough. */
     169    if (block_size >= the_size) { /* the_block is large enough. */
    171170
    172171      _H_uptr_t user_addr;
     
    190189
    191190      /* Make sure 'user_addr' calculated didn't run out of 'the_block'. */
    192       if(user_addr >= user_area) {
     191      if (user_addr >= user_area) {
    193192
    194193        /* The block seems to be acceptable. Check if the remainder of
    195194           'the_block' is less than 'min_block_size' so that 'the_block' won't
    196195           actually be split at the address we assume. */
    197         if(user_addr - user_area < the_heap->min_block_size) {
     196        if (user_addr - user_area < the_heap->min_block_size) {
    198197
    199198          /* The block won't be split, so 'user_addr' will be equal to the
     
    207206           distance within [0,page_size) range allows resurrection by
    208207           aligning user pointer down to the nearest 'page_size' boundary.) */
    209           if(aligned_user_addr - user_addr >= page_size) {
     208          if (aligned_user_addr - user_addr >= page_size) {
    210209
    211210            /* The user pointer will be too far from 'user_addr'. See if we
     
    214213            aligned_user_addr = user_addr;
    215214            _Heap_Align_up_uptr(&aligned_user_addr, alignment);
    216             if(aligned_user_addr - user_addr >= page_size) {
     215            if (aligned_user_addr - user_addr >= page_size) {
    217216              /* No, we can't use the block */
    218               aligned_user_addr = 0;
    219             }
     217              goto exit_point;
    220218          }
    221219        }
    222 
    223         if(aligned_user_addr) {
    224 
    225           /* The block is indeed acceptable: calculate the size of the block
    226              to be allocated and perform allocation. */
    227           uint32_t const alloc_size =
    228             block_end - user_addr + HEAP_BLOCK_USER_OFFSET;
    229 
    230           _HAssert(_Heap_Is_aligned_ptr((void*)aligned_user_addr, alignment));
    231 
    232           the_block = block_allocate(the_heap, the_block, alloc_size);
    233 
    234           stats->searches += search_count + 1;
    235           stats->allocs += 1;
    236 
    237           check_result(the_heap, the_block, user_addr,
    238             aligned_user_addr, size);
    239 
    240           user_ptr = (void*)aligned_user_addr;
    241           break;
    242         }
     220      }
     221
     222      /* The block is indeed acceptable: calculate the size of the block
     223         to be allocated and perform allocation. */
     224      uint32_t const alloc_size =
     225          block_end - user_addr + HEAP_BLOCK_USER_OFFSET;
     226
     227      _HAssert(_Heap_Is_aligned_ptr((void*)aligned_user_addr, alignment));
     228
     229      the_block = block_allocate(the_heap, the_block, alloc_size);
     230
     231      stats->searches += search_count + 1;
     232      stats->allocs += 1;
     233
     234      check_result(the_heap, the_block, user_addr,
     235        aligned_user_addr, size);
     236
     237        user_ptr = (void*)aligned_user_addr;
     238        break;
    243239      }
    244240    }
    245241  }
    246242
    247   if(stats->max_search < search_count)
     243exit_point:
     244  if (stats->max_search < search_count)
    248245    stats->max_search = search_count;
    249246
Note: See TracChangeset for help on using the changeset viewer.