Skip to content

Commit

Permalink
Fix DSCNode create and destroy call
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-jones committed Apr 25, 2024
1 parent c168dce commit 5bfed45
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/dsc_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool dsc_list_push_front(DSCList list, int value) {
return false;
}

DSCNode new_head = dsc_node_create(value);
DSCNode new_head = dsc_node_init(value);
if (new_head == NULL) {
dsc_set_error(DSC_ERROR_OUT_OF_MEMORY);
return false;
Expand All @@ -122,7 +122,7 @@ bool dsc_list_push_back(DSCList list, int value) {
return false;
}

DSCNode new_node = dsc_node_create(value);
DSCNode new_node = dsc_node_init(value);
if (new_node == NULL) {
dsc_set_error(DSC_ERROR_OUT_OF_MEMORY);
return false;
Expand Down Expand Up @@ -161,7 +161,7 @@ bool dsc_list_insert(DSCList list, int value, int position) {
return false;
}

DSCNode new_node = dsc_node_create(value);
DSCNode new_node = dsc_node_init(value);
if (new_node == NULL) {
dsc_set_error(DSC_ERROR_OUT_OF_MEMORY);
return false;
Expand Down Expand Up @@ -237,7 +237,7 @@ bool dsc_list_remove(DSCList list, int value) {
list->head = list->head->next;
list->size--;

dsc_node_destroy(old_head);
dsc_node_deinit(old_head);

dsc_set_error(DSC_ERROR_NONE);
return true;;
Expand All @@ -252,7 +252,7 @@ bool dsc_list_remove(DSCList list, int value) {
prev->next = curr->next;
list->size--;

dsc_node_destroy(curr);
dsc_node_deinit(curr);

dsc_set_error(DSC_ERROR_NONE);
return true;
Expand Down Expand Up @@ -284,7 +284,7 @@ bool dsc_list_remove_all(DSCList list, int value) {
list->head = list->head->next;
list->size--;

dsc_node_destroy(old_head);
dsc_node_deinit(old_head);
}

DSCNode prev = list->head;
Expand All @@ -295,7 +295,7 @@ bool dsc_list_remove_all(DSCList list, int value) {
prev->next = curr->next;
list->size--;

dsc_node_destroy(curr);
dsc_node_deinit(curr);
}

prev = curr;
Expand Down

0 comments on commit 5bfed45

Please sign in to comment.