diff --git a/src/rb-tree.h b/src/rb-tree.h index 143801e..69447f4 100644 --- a/src/rb-tree.h +++ b/src/rb-tree.h @@ -107,7 +107,7 @@ typedef int (*RBTreeCompareFunc)(RBTreeValue data1, RBTreeValue data2); */ typedef enum { RB_TREE_NODE_RED, - RB_TREE_NODE_BLACK + RB_TREE_NODE_BLACK, } RBTreeNodeColor; /** diff --git a/src/sortedarray.c b/src/sortedarray.c index be28d61..a45e7e7 100644 --- a/src/sortedarray.c +++ b/src/sortedarray.c @@ -52,9 +52,6 @@ unsigned int sortedarray_length(SortedArray *array) SortedArray *sortedarray_new(unsigned int length, SortedArrayCompareFunc cmp_func) { - SortedArrayValue *array; - SortedArray *sortedarray; - if (cmp_func == NULL) { return NULL; } @@ -64,12 +61,12 @@ SortedArray *sortedarray_new(unsigned int length, length = 16; } - array = malloc(sizeof(SortedArrayValue) * length); + SortedArrayValue *array = malloc(sizeof(SortedArrayValue) * length); if (array == NULL) { return NULL; } - sortedarray = malloc(sizeof(SortedArray)); + SortedArray *sortedarray = malloc(sizeof(SortedArray)); if (sortedarray == NULL) { free(array); return NULL; @@ -121,7 +118,6 @@ int sortedarray_remove_range(SortedArray *sortedarray, unsigned int index, int sortedarray_insert(SortedArray *sortedarray, SortedArrayValue data) { unsigned int left, right, index; - int order; if (sortedarray == NULL) { return 0; @@ -136,8 +132,9 @@ int sortedarray_insert(SortedArray *sortedarray, SortedArrayValue data) while (left != right) { index = (left + right) / 2; - order = sortedarray->cmp_func(data, sortedarray->data[index]); + int order = + sortedarray->cmp_func(data, sortedarray->data[index]); if (order < 0) { /* value should be left of index */ right = index; @@ -189,7 +186,6 @@ int sortedarray_insert(SortedArray *sortedarray, SortedArrayValue data) int sortedarray_index_of(SortedArray *sortedarray, SortedArrayValue data) { unsigned int left, right, index; - int order; if (sortedarray == NULL) { return -1; @@ -204,8 +200,9 @@ int sortedarray_index_of(SortedArray *sortedarray, SortedArrayValue data) while (left != right) { index = (left + right) / 2; - order = sortedarray->cmp_func(data, sortedarray->data[index]); + int order = + sortedarray->cmp_func(data, sortedarray->data[index]); if (order < 0) { /* value should be left */ right = index; diff --git a/test/test-hash-table.c b/test/test-hash-table.c index 9e86fdf..26d6b7b 100644 --- a/test/test-hash-table.c +++ b/test/test-hash-table.c @@ -166,7 +166,6 @@ void test_hash_table_iterating(void) { HashTable *hash_table; HashTableIterator iterator; - HashTablePair pair; int count; hash_table = generate_hash_table(); @@ -185,7 +184,7 @@ void test_hash_table_iterating(void) assert(count == NUM_TEST_VALUES); /* Test iter_next after iteration has completed. */ - pair = hash_table_iter_next(&iterator); + HashTablePair pair = hash_table_iter_next(&iterator); assert(pair.value == HASH_TABLE_NULL); hash_table_free(hash_table); @@ -398,8 +397,6 @@ void test_hash_iterator_key_pair() HashTable *hash_table; HashTableIterator iterator; HashTablePair pair; - int *key, *val; - hash_table = hash_table_new(int_hash, int_equal); /* Add some values */ @@ -413,8 +410,8 @@ void test_hash_iterator_key_pair() /* Retrieve both Key and Value */ pair = hash_table_iter_next(&iterator); - key = (int *) pair.key; - val = (int *) pair.value; + int *key = (int *) pair.key; + int *val = (int *) pair.value; assert(*key == *val); }