Changeset ac893a9 in rtems


Ignore:
Timestamp:
Aug 6, 2009, 8:43:30 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
d68c788
Parents:
f0bf3326
Message:

2009-08-06 Chris Johns <chrisj@…>

  • score/src/objectextendinformation.c: Ensure that nothing is moved or copied until all memory is successfully allocated.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rf0bf3326 rac893a9  
     12009-08-06      Chris Johns <chrisj@rtems.org>
     2
     3        * score/src/objectextendinformation.c: Ensure that nothing is moved or
     4        copied until all memory is successfully allocated.
     5
    162009-08-06      Joel Sherrill <joel.sherrill@OARcorp.com>
    27
  • cpukit/score/src/objectextendinformation.c

    rf0bf3326 rac893a9  
    5454  uint32_t          minimum_index;
    5555  uint32_t          index;
     56  void             *new_object_block;
    5657
    5758  /*
     
    7778  }
    7879
     80  /*
     81   * Allocate the name table, and the objects and if it fails either return or
     82   * generate a fatal error depending on auto-extending being active.
     83   */
     84 
     85  new_object_block =
     86    _Workspace_Allocate(
     87      (information->allocation_size * information->size)
     88    );
     89 
     90  if ( new_object_block == NULL ) {
     91    if ( information->auto_extend ) {
     92      return;
     93    }
     94    else {
     95      _Internal_error_Occurred(
     96        INTERNAL_ERROR_CORE,
     97        true,
     98        INTERNAL_ERROR_WORKSPACE_ALLOCATION
     99      );
     100    }
     101  }
     102 
    79103  /*
    80104   *  If the index_base is the maximum we need to grow the tables.
     
    113137    block_count++;
    114138
    115     maximum = information->maximum + information->allocation_size;
     139    maximum = (uint32_t) information->maximum + information->allocation_size;
    116140
    117141    /*
     
    120144     *  case of 16-bit Ids, this is only 256 object instances.
    121145     */
    122     if ( maximum > OBJECTS_ID_FINAL_INDEX )
     146    if ( maximum > OBJECTS_ID_FINAL_INDEX ) {
     147      if ( !_Workspace_Free( new_object_block ) ) {
     148        _Internal_error_Occurred(
     149          INTERNAL_ERROR_CORE,
     150          true,
     151          INTERNAL_ERROR_WORKSPACE_ALLOCATION
     152        );
     153      }
    123154      return;
     155    }
    124156
    125157    /*
     
    132164    object_blocks = (void**) _Workspace_Allocate( block_size );
    133165
    134     if ( !object_blocks )
     166    if ( !object_blocks ) {
     167      if ( !_Workspace_Free( new_object_block ) ) {
     168        _Internal_error_Occurred(
     169          INTERNAL_ERROR_CORE,
     170          true,
     171          INTERNAL_ERROR_WORKSPACE_ALLOCATION
     172        );
     173      }
    135174      return;
    136 
     175    }
     176   
    137177    /*
    138178     *  Break the block into the various sections.
     
    198238    information->inactive_per_block = inactive_per_block;
    199239    information->local_table = local_table;
    200     information->maximum = maximum;
     240    information->maximum = (Objects_Maximum) maximum;
    201241    information->maximum_id = _Objects_Build_id(
    202242        information->the_api,
     
    215255
    216256  /*
    217    *  Allocate the name table, and the objects
    218    */
    219 
    220   if ( information->auto_extend ) {
    221     information->object_blocks[ block ] =
    222       _Workspace_Allocate(
    223         (information->allocation_size * information->size)
    224       );
    225 
    226     if ( !information->object_blocks[ block ] )
    227       return;
    228   }
    229   else {
    230     information->object_blocks[ block ] =
    231       _Workspace_Allocate_or_fatal_error(
    232         (information->allocation_size * information->size)
    233       );
    234   }
     257   *  Assign the new object block to the object block table.
     258   */
     259
     260  information->object_blocks[ block ] = new_object_block;
    235261
    236262  /*
     
    266292
    267293  information->inactive_per_block[ block ] = information->allocation_size;
    268   information->inactive += information->allocation_size;
     294  information->inactive =
     295    (Objects_Maximum)(information->inactive + information->allocation_size);
    269296}
Note: See TracChangeset for help on using the changeset viewer.