cfulist_delete_data now works for the first item
This function would crash for the first item. Now it calls cfulist_dequeue to remove the first element when necessary.
This commit is contained in:
parent
b4faaca915
commit
5af4f108dc
@ -425,9 +425,14 @@ cfulist_delete_data(cfulist_t *list, void *data) {
|
||||
if (list->entries) {
|
||||
for (ptr = list->entries; ptr && ptr->data != data; ptr = ptr->next)
|
||||
;
|
||||
|
||||
if (ptr && ptr->data == data) {
|
||||
(ptr->prev)->next = ptr->next;
|
||||
free (ptr);
|
||||
if (!ptr->prev) {
|
||||
cfulist_dequeue (list);
|
||||
} else {
|
||||
(ptr->prev)->next = ptr->next;
|
||||
free (ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user