slist.c
/*----------------------------------------------------------------------*/
/*    SearchSList();                                                    */
/*                                                                      */
/*    Search a list for an element, and return a pointer to the node    */
/*    containing the element, else return NULL.                         */
/*----------------------------------------------------------------------*/
SearchSList();
Search a list for an element, and return a pointer to the node
containing the element, else return NULL.
SearchSList () ; Search a list for an element and return a pointer to the node containing the element else return NULL .
slistnode_t *SearchSList(slist_t * p_list, void *p_element,
                         int (*cfunc) (void *, void *))
{
    slistnode_t *p_node;
    if (p_list && p_list->L_elements)
    {
        p_node = p_list->L_first;
        while (p_node)
        {
            if (!cfunc(p_node->L_element, p_element))
                return p_node;
            else
                p_node = p_node->L_next;
        }
    }
    return NULL;
}
slistnode_t * SearchSList ( slist_t * p_list , void * p_element , int ( * cfunc ) ( void * , void * ) ) { slistnode_t * p_node ; if ( p_list && p_list -> L_elements ) { p_node = p_list -> L_first ; while ( p_node ) { if ( ! cfunc ( p_node -> L_element , p_element ) ) return p_node ; else p_node = p_node -> L_next ; } } return NULL ; }
SearchSList();
Search a list for an element, and return a pointer to the node
containing the element, else return NULL.
SearchSList () ; Search a list for an element and return a pointer to the node containing the element else return NULL .