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_dlnode(struct dlist* list, struct dl_node* new_node,
                           int direction)
{
    if (list == NULL || new_node == NULL)
        return (NULL);
    if (list->marker == NULL) // in case the marker ends up unset
        list->marker = list->head;
    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;
    return (list->marker);
}
/* internal use only
 * Insert dl_node  at marker.
 * If direction true it inserts after.
 * If direction false it inserts before.
 * move marker to inserted node
 * return pointer to inserted node
 */
internal use only
Insert dl_node  at marker.
If direction true it inserts after.
If direction false it inserts before.
move marker to inserted node
return pointer to inserted node
internal use only Insert dl_node 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_dlnode(struct dlist* list, struct dl_node* new_node,
                           int direction)
{
    if (list == NULL || new_node == NULL)
        return (NULL);
    if (list->marker == NULL) 
        list->marker = list->head;
    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;
    return (list->marker);
}
void * _dlist_insert_dlnode ( struct dlist * list , struct dl_node * new_node , int direction ) { if ( list == NULL || new_node == NULL ) return ( NULL ) ; if ( list -> marker == NULL ) list -> marker = list -> head ; 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 ; return ( list -> marker ) ; }
internal use only
 Insert dl_node  at marker.
internal use only Insert dl_node at marker .
// in case the marker ends up unset