list.c
/* Insert element after node 'prev_node'*/
Insert element after node 'prev_node'
Insert element after node ' prev_node '
static void list_insert_after(list_t *_list, list_node_t * prev_node, void *element) 
{
	list_node_t *new_node, *next_node;
	list_node_create(&new_node,element);
	list_node_set_prev(new_node, prev_node);
	if (prev_node != NULL) {
		list_node_set_next(new_node,list_node_get_next(prev_node));
		list_node_set_next(prev_node,new_node);
	} else {
		list_node_set_next(new_node,_list->head);
		_list->head = new_node;
	}
	next_node = list_node_get_next(new_node);
	if (next_node != NULL) list_node_set_prev(next_node,new_node);
	else _list->tail = new_node;
	_list->len++;
}
static void list_insert_after ( list_t * _list , list_node_t * prev_node , void * element ) { list_node_t * new_node , * next_node ; list_node_create ( & new_node , element ) ; list_node_set_prev ( new_node , prev_node ) ; if ( prev_node != NULL ) { list_node_set_next ( new_node , list_node_get_next ( prev_node ) ) ; list_node_set_next ( prev_node , new_node ) ; } else { list_node_set_next ( new_node , _list -> head ) ; _list -> head = new_node ; } next_node = list_node_get_next ( new_node ) ; if ( next_node != NULL ) list_node_set_prev ( next_node , new_node ) ; else _list -> tail = new_node ; _list -> len ++ ; }
Insert element after node 'prev_node'
Insert element after node ' prev_node '
// Adjust previous and new node // Adjust next node too