From 17538bcfbc53c966d014379e0f6a5f1314d4fb09 Mon Sep 17 00:00:00 2001 From: a bellenir Date: Fri, 29 Aug 2014 19:48:50 +0000 Subject: [PATCH] c99-allowed cleanup --- source/list/list.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/source/list/list.c b/source/list/list.c index e5492d2..6dae492 100644 --- a/source/list/list.c +++ b/source/list/list.c @@ -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; -- 2.52.0