summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/key.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-06-24 14:00:08 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-07-01 08:24:31 +0200
commitfdb45d6b26b6e31ab168f817d25a847f1847d4a1 (patch)
treedab5ed17112f010299fe6e000cbf42263fd84315 /cpukit/posix/src/key.c
parentdoc: Fix interrupt level ARM documentation (diff)
downloadrtems-fdb45d6b26b6e31ab168f817d25a847f1847d4a1.tar.bz2
score: Freechain handler API changes
Replace the extend function with an allocator since this fits better to the current use case.
Diffstat (limited to 'cpukit/posix/src/key.c')
-rw-r--r--cpukit/posix/src/key.c53
1 files changed, 14 insertions, 39 deletions
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 )
+ );
}
/**