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/regionreturnsegment.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/regionreturnsegment.c')
-rw-r--r-- | cpukit/rtems/src/regionreturnsegment.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/cpukit/rtems/src/regionreturnsegment.c b/cpukit/rtems/src/regionreturnsegment.c index c7147bbe19..8ec84fb9c4 100644 --- a/cpukit/rtems/src/regionreturnsegment.c +++ b/cpukit/rtems/src/regionreturnsegment.c @@ -25,27 +25,22 @@ rtems_status_code rtems_region_return_segment( void *segment ) { - rtems_status_code status; - Region_Control *the_region; + Region_Control *the_region; - _RTEMS_Lock_allocator(); + the_region = _Region_Get_and_lock( id ); - the_region = _Region_Get( id ); + if ( the_region == NULL ) { + return RTEMS_INVALID_ID; + } - if ( the_region != NULL ) { - if ( _Region_Free_segment( the_region, segment ) ) { - the_region->number_of_used_blocks -= 1; + if ( _Region_Free_segment( the_region, segment ) ) { + the_region->number_of_used_blocks -= 1; - /* Unlocks allocator */ - _Region_Process_queue( the_region ); - return RTEMS_SUCCESSFUL; - } else { - status = RTEMS_INVALID_ADDRESS; - } - } else { - status = RTEMS_INVALID_ID; + /* Unlocks allocator */ + _Region_Process_queue( the_region ); + return RTEMS_SUCCESSFUL; } - _RTEMS_Unlock_allocator(); - return status; + _Region_Unlock( the_region ); + return RTEMS_INVALID_ADDRESS; } |