]> git.mdlowis.com Git - projs/libcds.git/commitdiff
c99-allowed cleanup
authora bellenir <a@bellenir.com>
Fri, 29 Aug 2014 19:48:50 +0000 (19:48 +0000)
committera bellenir <a@bellenir.com>
Fri, 29 Aug 2014 19:48:50 +0000 (19:48 +0000)
source/list/list.c

index e5492d2b047d30e82a1ee6254a2cf3a30073dfe2..6dae492ceda1e3e50bc0c66ce4d1a93bf98e26a8 100644 (file)
@@ -55,10 +55,9 @@ list_node_t* list_prev(list_t* list, list_node_t* node){
 
 list_node_t* list_at(list_t* list, size_t index)
 {
-    list_node_t* node;
-    size_t cur_index = 0;
     assert(NULL != list);
-    node = list->head;
+    list_node_t* node = list->head;
+    size_t cur_index = 0;
     while( NULL != node && cur_index != index)
     {
         node = node->next;
@@ -69,10 +68,9 @@ list_node_t* list_at(list_t* list, size_t index)
 
 int list_index_of(list_t* list, list_node_t* node)
 {
-    int i = 0;
-    list_node_t* edon;
     assert(NULL != list);
-    edon = list->head;
+    int i = 0;
+    list_node_t* edon = list->head;
     while( NULL != edon && edon != node)
     {
         edon = edon->next;
@@ -93,9 +91,8 @@ list_node_t* list_push_back( list_t* list, void* contents )
 
 list_node_t* list_pop_front( list_t* list )
 {
-    list_node_t* node;
     assert(NULL != list);
-    node = list->head;
+    list_node_t* node = list->head;
     if(node)
     {
         mem_retain(node);
@@ -106,9 +103,8 @@ list_node_t* list_pop_front( list_t* list )
 
 list_node_t* list_pop_back( list_t* list )
 {
-    list_node_t* node;
     assert(NULL != list);
-    node = list->tail;
+    list_node_t* node = list->tail;
     if(node)
     {
         mem_retain(node);
@@ -119,9 +115,9 @@ list_node_t* list_pop_back( list_t* list )
 
 list_node_t* list_insert( list_t* list, size_t index, void* contents)
 {
-    list_node_t *prev, *new_node = NULL;
     assert(NULL != list);
-    prev = (index > 0 ? list_at(list, index-1) : NULL);
+    list_node_t* new_node = NULL;
+    list_node_t* prev = (index > 0 ? list_at(list, index-1) : NULL);
     if(prev || index == 0)
         new_node = list_insert_after(list, prev, contents);
     else
@@ -131,10 +127,10 @@ list_node_t* list_insert( list_t* list, size_t index, void* contents)
 
 list_node_t* list_insert_after( list_t* list, list_node_t* node, void* contents)
 {
-    list_node_t *next, *new_node = list_new_node(contents);
     assert(NULL != list);
+    list_node_t* new_node = list_new_node(contents);
     assert(NULL != new_node);
-    next = (node ? node->next : list->head);
+    list_node_t* next = (node ? node->next : list->head);
     new_node->prev = node;
     new_node->next = next;
     *(node ? &(node->next) : &(list->head)) = new_node;
@@ -161,9 +157,8 @@ void list_delete_node(list_t* list, list_node_t* node)
 
 void list_clear(list_t* list)
 {
-    list_node_t* node;
     assert(NULL != list);
-    node = list->tail;
+    list_node_t* node = list->tail;
     while(NULL != node)
     {
         list_node_t* p = node->prev;