diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-08 06:56:46 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-12 07:36:19 +0200 |
commit | 1142f5593a5b6ab65d47bafb749e0709c7d2daa2 (patch) | |
tree | 44d5b886a880307bd6f38550a7275071f38965a7 /cpukit/rtems/src/regionextend.c | |
parent | score: Simplify _Objects_Get_no_protection() (diff) | |
download | rtems-1142f5593a5b6ab65d47bafb749e0709c7d2daa2.tar.bz2 |
rtems: Add and use _Region_Get_and_lock()
Get region and lock allocator in _Region_Get_and_lock() in case the
region exists and unlock it in _Region_Unlock().
Diffstat (limited to 'cpukit/rtems/src/regionextend.c')
-rw-r--r-- | cpukit/rtems/src/regionextend.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/cpukit/rtems/src/regionextend.c b/cpukit/rtems/src/regionextend.c index b1df066f25..e6cadf8750 100644 --- a/cpukit/rtems/src/regionextend.c +++ b/cpukit/rtems/src/regionextend.c @@ -34,29 +34,27 @@ rtems_status_code rtems_region_extend( return RTEMS_INVALID_ADDRESS; } - _RTEMS_Lock_allocator(); - - the_region = _Region_Get( id ); - - if ( the_region != NULL ) { - amount_extended = _Heap_Extend( - &the_region->Memory, - starting_address, - length, - 0 - ); - - if ( amount_extended > 0 ) { - the_region->length += amount_extended; - the_region->maximum_segment_size += amount_extended; - status = RTEMS_SUCCESSFUL; - } else { - status = RTEMS_INVALID_ADDRESS; - } + the_region = _Region_Get_and_lock( id ); + + if ( the_region == NULL ) { + return RTEMS_INVALID_ID; + } + + amount_extended = _Heap_Extend( + &the_region->Memory, + starting_address, + length, + 0 + ); + + if ( amount_extended > 0 ) { + the_region->length += amount_extended; + the_region->maximum_segment_size += amount_extended; + status = RTEMS_SUCCESSFUL; } else { - status = RTEMS_INVALID_ID; + status = RTEMS_INVALID_ADDRESS; } - _RTEMS_Unlock_allocator(); + _Region_Unlock( the_region ); return status; } |