From bc93f30f3954120948cdb03eef95035316a1ba66 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 7 Jul 2009 22:47:03 +0000 Subject: 2009-07-07 Chris Johns * score/src/objectshrinkinformation.c: Rework loop to simplify and remove dead code. --- cpukit/score/src/objectshrinkinformation.c | 50 ++++++++++-------------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'cpukit/score/src/objectshrinkinformation.c') diff --git a/cpukit/score/src/objectshrinkinformation.c b/cpukit/score/src/objectshrinkinformation.c index ad4f4d7960..914fe2ac5d 100644 --- a/cpukit/score/src/objectshrinkinformation.c +++ b/cpukit/score/src/objectshrinkinformation.c @@ -59,47 +59,31 @@ void _Objects_Shrink_information( */ index_base = _Objects_Get_index( information->minimum_id ); - block_count = ( information->maximum - index_base ) / information->allocation_size; + block_count = (information->maximum - index_base) / + information->allocation_size; for ( block = 0; block < block_count; block++ ) { - if ( information->inactive_per_block[ block ] == information->allocation_size ) { - - /* - * XXX - Not to sure how to use a chain where you need to iterate and - * and remove elements. - */ - - the_object = (Objects_Control *) information->Inactive.first; + if ( information->inactive_per_block[ block ] == + information->allocation_size ) { /* * Assume the Inactive chain is never empty at this point */ + the_object = (Objects_Control *) information->Inactive.first; do { - index = _Objects_Get_index( the_object->id ); - - if ((index >= index_base) && - (index < (index_base + information->allocation_size))) { - - /* - * Get the next node before the node is extracted - */ - - extract_me = the_object; - - if ( !_Chain_Is_last( &the_object->Node ) ) - the_object = (Objects_Control *) the_object->Node.next; - else - the_object = NULL; - - _Chain_Extract( &extract_me->Node ); - } - else { - the_object = (Objects_Control *) the_object->Node.next; - } - } - while ( the_object && !_Chain_Is_last( &the_object->Node ) ); - + index = _Objects_Get_index( the_object->id ); + /* + * Get the next node before the node is extracted + */ + extract_me = the_object; + the_object = (Objects_Control *) the_object->Node.next; + if ((index >= index_base) && + (index < (index_base + information->allocation_size))) { + _Chain_Extract( &extract_me->Node ); + } + } + while ( the_object ); /* * Free the memory and reset the structures in the object' information */ -- cgit v1.2.3