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,11 +425,16 @@ cfulist_delete_data(cfulist_t *list, void *data) {
|
|||||||
if (list->entries) {
|
if (list->entries) {
|
||||||
for (ptr = list->entries; ptr && ptr->data != data; ptr = ptr->next)
|
for (ptr = list->entries; ptr && ptr->data != data; ptr = ptr->next)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (ptr && ptr->data == data) {
|
if (ptr && ptr->data == data) {
|
||||||
|
if (!ptr->prev) {
|
||||||
|
cfulist_dequeue (list);
|
||||||
|
} else {
|
||||||
(ptr->prev)->next = ptr->next;
|
(ptr->prev)->next = ptr->next;
|
||||||
free (ptr);
|
free (ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unlock_list(list);
|
unlock_list(list);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user