On Tue, Jun 30, 2015 at 5:22 AM, Hans de Goede <[email protected]> wrote:

>
> +       if (elm->next == NULL && elm->prev == NULL)
>> +               return;
>> +
>>         elm->prev->next = elm->next;
>>         elm->next->prev = elm->prev;
>>         elm->next = NULL;
>>
>>
> I do not think this is a good idea, most list implementations
> people are used to do not allow this and consider a double
> remove / del a bug.
>

I don't think he is trying to fix double-remove. What he is trying to fix
is "it was never added to a list in the first place".

I can see the desirability of this crashing if the caller thinks the
element really should be in a list. Maybe a better solution is to add an
inline "list_is_inserted(x)" that returns whether the element is in a list
(by checking one or both pointers). Then the caller can call this before
calling list_remove if it wants this check. I think you could even
distinguish double-remove by only clearing one of the pointers on remove,
that might help when debugging.
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to