openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/sysfsutils/2.1.0-r5/sysfsutils-2.1.0/lib/dlist.c
void* dlist_insert(Dlist* list, void* data, int direction)
{
    DL_node* new_node = NULL;
    if (list == NULL || data == NULL)
        return (NULL);
    if (list->marker == NULL) // in case the marker ends up unset
        list->marker = list->head;
    if ((new_node = malloc(sizeof(DL_node))))
    {
        new_node->data = data;
        new_node->prev = NULL;
        new_node->next = NULL;
        list->count++;
        if (list->head->next == NULL) // no l
        {
            list->head->next = list->head->prev = new_node;
            new_node->prev = list->head;
            new_node->next = list->head;
        }
        else if (direction)
        {
            new_node->next = list->marker->next;
            new_node->prev = list->marker;
            list->marker->next->prev = new_node;
            list->marker->next = new_node;
        }
        else
        {
            new_node->prev = list->marker->prev;
            new_node->next = list->marker;
            list->marker->prev->next = new_node;
            list->marker->prev = new_node;
        }
        list->marker = new_node;
    }
    else
    {
        return (NULL);
    }
    return (list->marker->data);
}
/*
 * Insert node containing data at marker.
 * If direction true it inserts after.
 * If direction false it inserts before.
 * move marker to inserted node
 * return pointer to inserted node
 */
Insert node containing data at marker.
If direction true it inserts after.
If direction false it inserts before.
move marker to inserted node
return pointer to inserted node
Insert node containing data at marker . If direction true it inserts after . If direction false it inserts before . move marker to inserted node return pointer to inserted node
void* dlist_insert(Dlist* list, void* data, int direction)
{
    DL_node* new_node = NULL;
    if (list == NULL || data == NULL)
        return (NULL);
    if (list->marker == NULL) 
        list->marker = list->head;
    if ((new_node = malloc(sizeof(DL_node))))
    {
        new_node->data = data;
        new_node->prev = NULL;
        new_node->next = NULL;
        list->count++;
        if (list->head->next == NULL) 
        {
            list->head->next = list->head->prev = new_node;
            new_node->prev = list->head;
            new_node->next = list->head;
        }
        else if (direction)
        {
            new_node->next = list->marker->next;
            new_node->prev = list->marker;
            list->marker->next->prev = new_node;
            list->marker->next = new_node;
        }
        else
        {
            new_node->prev = list->marker->prev;
            new_node->next = list->marker;
            list->marker->prev->next = new_node;
            list->marker->prev = new_node;
        }
        list->marker = new_node;
    }
    else
    {
        return (NULL);
    }
    return (list->marker->data);
}
void * dlist_insert ( Dlist * list , void * data , int direction ) { DL_node * new_node = NULL ; if ( list == NULL || data == NULL ) return ( NULL ) ; if ( list -> marker == NULL ) list -> marker = list -> head ; if ( ( new_node = malloc ( sizeof ( DL_node ) ) ) ) { new_node -> data = data ; new_node -> prev = NULL ; new_node -> next = NULL ; list -> count ++ ; if ( list -> head -> next == NULL ) { list -> head -> next = list -> head -> prev = new_node ; new_node -> prev = list -> head ; new_node -> next = list -> head ; } else if ( direction ) { new_node -> next = list -> marker -> next ; new_node -> prev = list -> marker ; list -> marker -> next -> prev = new_node ; list -> marker -> next = new_node ; } else { new_node -> prev = list -> marker -> prev ; new_node -> next = list -> marker ; list -> marker -> prev -> next = new_node ; list -> marker -> prev = new_node ; } list -> marker = new_node ; } else { return ( NULL ) ; } return ( list -> marker -> data ) ; }
Insert node containing data at marker.
Insert node containing data at marker .
// in case the marker ends up unset // no l