From: a bellenir Date: Thu, 31 Jul 2014 23:55:31 +0000 (+0000) Subject: push front/back simply wrap list_insert_after X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=e8b5e852bd1ee487868cc49d04678ae7fd362149;p=projs%2Flibcds.git push front/back simply wrap list_insert_after --- 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 )