in common/src/s_list.c [286:330]
int s_list_for_each(PS_LIST_ENTRY list_head, S_LIST_ACTION_FUNCTION action_function, const void* action_context)
{
int result;
if (
/* Codes_SRS_S_LIST_07_033: [ If list_head is NULL, s_list_for_each shall fail and return a non - zero value. ]*/
(list_head == NULL) ||
/* Codes_SRS_S_LIST_07_034: [ If action_function is NULL, s_list_for_each shall fail and return a non - zero value. ]*/
(action_function == NULL))
{
LogError("Invalid arguments (list_head=%p, action_function=%p)", list_head, action_function);
result = MU_FAILURE;
}
else
{
PS_LIST_ENTRY current_item = list_head->next;
/* Codes_SRS_S_LIST_07_035: [ s_list_for_each shall iterate through all entries in the list, invoke action_function for each one of themand return zero on success. ]*/
while (current_item != NULL)
{
bool continue_processing = false;
if (action_function(current_item, action_context, &continue_processing) != 0)
{
/* Codes_SRS_S_LIST_07_036: [ If the action_function fails, s_list_for_each shall fail and return a non - zero value. ]*/
LogError("failure in actionFunction(current_item = %p, action_context = %p, &continue_processing = %p)", current_item, action_context, &continue_processing);
result = MU_FAILURE;
break;
}
else
{
if (continue_processing == false)
{
/* Codes_SRS_S_LIST_07_037: [ If the action_function returns continue_processing as false, s_list_for_each shall stop iterating through the list and return. ]*/
result = 0;
break;
}
}
current_item = current_item->next;
}
result = 0;
}
return result;
}