Skip to content

Commit 26056b0

Browse files
committed
Remove duplicate-instruction in append_element-function
1 parent 82d3409 commit 26056b0

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/dynamic_array.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ ERROR_CODE init_array(DynamicArray* array) {
2222
return NOERROR;
2323
}
2424

25-
2625
/*
2726
Helper function, to check if the given dynamic-array is invalid.
2827
@@ -106,23 +105,22 @@ ERROR_CODE append_element(DynamicArray* array, size_t element_size, void* elemen
106105
if (array->head_ptr == NULL) {
107106
// First element in array
108107
array->head_ptr = current_ptr;
109-
array->tail_ptr = current_ptr;
110108
current_ptr->prev_ptr = NULL;
111109

112110
} else if (array->head_ptr == array->tail_ptr) {
113111
// Second element in array
114112
array->head_ptr->next_ptr = current_ptr;
115-
array->tail_ptr = current_ptr;
116113
current_ptr->next_ptr = NULL;
117114
current_ptr->prev_ptr = array->head_ptr;
118115

119116
} else {
120117
// At least two elements in array
121118
array->tail_ptr->next_ptr = current_ptr;
122119
current_ptr->prev_ptr = array->tail_ptr;
123-
array->tail_ptr = current_ptr;
124120
}
125121

122+
array->tail_ptr = current_ptr;
123+
126124
return NOERROR;
127125
}
128126

0 commit comments

Comments
 (0)