]> git.mdlowis.com Git - projs/libcds.git/commitdiff
push front/back simply wrap list_insert_after
authora bellenir <a@bellenir.com>
Thu, 31 Jul 2014 23:55:31 +0000 (23:55 +0000)
committera bellenir <a@bellenir.com>
Thu, 31 Jul 2014 23:55:31 +0000 (23:55 +0000)
source/list/list.c

index 4df9a381f5e09b4f09bce75359a7721ceca07df9..27e13d1867883751fa4412b33956c4ae71fe4ec3 100644 (file)
@@ -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 )