From 1142f5593a5b6ab65d47bafb749e0709c7d2daa2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 8 Apr 2016 06:56:46 +0200 Subject: 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(). --- cpukit/rtems/src/regionresizesegment.c | 50 ++++++++++++++++------------------ 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'cpukit/rtems/src/regionresizesegment.c') diff --git a/cpukit/rtems/src/regionresizesegment.c b/cpukit/rtems/src/regionresizesegment.c index a21d1b9d44..303fce496f 100644 --- a/cpukit/rtems/src/regionresizesegment.c +++ b/cpukit/rtems/src/regionresizesegment.c @@ -37,38 +37,36 @@ rtems_status_code rtems_region_resize_segment( return RTEMS_INVALID_ADDRESS; } - _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 ) { - resize_status = _Heap_Resize_block( - &the_region->Memory, - segment, - (uint32_t) size, - &osize, - &avail_size - ); - *old_size = (uint32_t) osize; + resize_status = _Heap_Resize_block( + &the_region->Memory, + segment, + (uint32_t) size, + &osize, + &avail_size + ); + *old_size = (uint32_t) osize; - switch ( resize_status ) { - case HEAP_RESIZE_SUCCESSFUL: - /* Unlocks allocator */ - _Region_Process_queue( the_region ); - return RTEMS_SUCCESSFUL; + switch ( resize_status ) { + case HEAP_RESIZE_SUCCESSFUL: + /* Unlocks allocator */ + _Region_Process_queue( the_region ); + return RTEMS_SUCCESSFUL; - case HEAP_RESIZE_UNSATISFIED: - status = RTEMS_UNSATISFIED; - break; + case HEAP_RESIZE_UNSATISFIED: + status = RTEMS_UNSATISFIED; + break; - default: - status = RTEMS_INVALID_ADDRESS; - break; - } - } else { - status = RTEMS_INVALID_ID; + default: + status = RTEMS_INVALID_ADDRESS; + break; } - _RTEMS_Unlock_allocator(); + _Region_Unlock( the_region ); return status; } -- cgit v1.2.3