diff options
Diffstat (limited to 'cpukit/posix')
-rw-r--r-- | cpukit/posix/include/rtems/posix/keyimpl.h | 6 | ||||
-rw-r--r-- | cpukit/posix/src/key.c | 53 |
2 files changed, 15 insertions, 44 deletions
diff --git a/cpukit/posix/include/rtems/posix/keyimpl.h b/cpukit/posix/include/rtems/posix/keyimpl.h index a5c80d625b..6fd4d1348a 100644 --- a/cpukit/posix/include/rtems/posix/keyimpl.h +++ b/cpukit/posix/include/rtems/posix/keyimpl.h @@ -156,11 +156,7 @@ RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get ( _Objects_Get( &_POSIX_Keys_Information, (Objects_Id) id, location ); } -RTEMS_INLINE_ROUTINE POSIX_Keys_Key_value_pair * -_POSIX_Keys_Key_value_pair_allocate( void ) -{ - return (POSIX_Keys_Key_value_pair *) _Freechain_Get( &_POSIX_Keys_Keypool ); -} +POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_pair_allocate( void ); RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_pair_free( POSIX_Keys_Key_value_pair *key_value_pair diff --git a/cpukit/posix/src/key.c b/cpukit/posix/src/key.c index 6753d57437..55c6590051 100644 --- a/cpukit/posix/src/key.c +++ b/cpukit/posix/src/key.c @@ -92,49 +92,24 @@ static uint32_t _POSIX_Keys_Get_initial_keypool_size( void ) return _Objects_Maximum_per_allocation( max ); } -static bool _POSIX_Keys_Keypool_extend( Freechain_Control *keypool ) +static void _POSIX_Keys_Initialize_keypool( void ) { - size_t bump_count = _POSIX_Keys_Get_keypool_bump_count(); - bool ok = bump_count > 0; - - if ( ok ) { - size_t size = bump_count * sizeof( POSIX_Keys_Key_value_pair ); - POSIX_Keys_Key_value_pair *nodes = _Workspace_Allocate( size ); - - ok = nodes != NULL; - - if ( ok ) { - _Chain_Initialize( - &keypool->Freechain, - nodes, - bump_count, - sizeof( *nodes ) - ); - } - } - - return ok; + _Freechain_Initialize( + &_POSIX_Keys_Keypool, + _Workspace_Allocate_or_fatal_error, + _POSIX_Keys_Get_initial_keypool_size(), + sizeof( POSIX_Keys_Key_value_pair ) + ); } -static void _POSIX_Keys_Initialize_keypool( void ) +POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_pair_allocate( void ) { - Freechain_Control *keypool = &_POSIX_Keys_Keypool; - size_t initial_count = _POSIX_Keys_Get_initial_keypool_size(); - - _Freechain_Initialize( keypool, _POSIX_Keys_Keypool_extend ); - - if ( initial_count > 0 ) { - size_t size = initial_count * sizeof( POSIX_Keys_Key_value_pair ); - POSIX_Keys_Key_value_pair *nodes = - _Workspace_Allocate_or_fatal_error( size ); - - _Chain_Initialize( - &keypool->Freechain, - nodes, - initial_count, - sizeof( *nodes ) - ); - } + return (POSIX_Keys_Key_value_pair *) _Freechain_Get( + &_POSIX_Keys_Keypool, + _Workspace_Allocate, + _POSIX_Keys_Get_keypool_bump_count(), + sizeof( POSIX_Keys_Key_value_pair ) + ); } /** |