forked from Imagelibrary/rtems
score: Accept NULL pointer in _Freechain_Put()
With this a _Freechain_Put( _Freechain_Get() ) works always.
This commit is contained in:
@@ -93,7 +93,8 @@ void *_Freechain_Get(
|
||||
* @brief Puts a node back onto the freechain.
|
||||
*
|
||||
* @param[in] freechain The freechain control.
|
||||
* @param[in] node The node to put back.
|
||||
* @param[in] node The node to put back. The node may be @c NULL, in this case
|
||||
* the function does nothing.
|
||||
*/
|
||||
void _Freechain_Put(
|
||||
Freechain_Control *freechain,
|
||||
|
||||
@@ -74,5 +74,7 @@ void *_Freechain_Get(
|
||||
|
||||
void _Freechain_Put( Freechain_Control *freechain, void *node )
|
||||
{
|
||||
if ( node != NULL ) {
|
||||
_Chain_Prepend_unprotected( &freechain->Free, node );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ static rtems_task Init(rtems_task_argument ignored)
|
||||
|
||||
/* check whether freechain put and get works correctly*/
|
||||
|
||||
_Freechain_Put(&fc, NULL);
|
||||
|
||||
puts( "INIT - Get node from freechain - OK" );
|
||||
node = _Freechain_Get(&fc, malloc, 1, sizeof(test_node));
|
||||
node->x = 1;
|
||||
|
||||
Reference in New Issue
Block a user