From e8b5e852bd1ee487868cc49d04678ae7fd362149 Mon Sep 17 00:00:00 2001 From: a bellenir Date: Thu, 31 Jul 2014 23:55:31 +0000 Subject: [PATCH] push front/back simply wrap list_insert_after --- source/list/list.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/source/list/list.c b/source/list/list.c index 4df9a38..27e13d1 100644 --- a/source/list/list.c +++ b/source/list/list.c @@ -87,31 +87,12 @@ int list_index_of(list_t* list, list_node_t* node) list_node_t* list_push_front( list_t* list, void* contents ) { - list_node_t* node = list_new_node( contents ); - node->next = list->head; - list->head = node; - if( NULL == list->tail ) - { - list->tail = node; - } - return node; + return list_insert_after(list, NULL, contents); } list_node_t* list_push_back( list_t* list, void* contents ) { - list_node_t* node = list_new_node( contents ); - node->next = NULL; - if( NULL == list->tail ) - { - list->head = node; - list->tail = node; - } - else - { - list->tail->next = node; - list->tail = node; - } - return node; + return list_insert_after(list, list->tail, contents); } list_node_t* list_pop_front( list_t* list ) -- 2.52.0