static void
_eo_callback_remove(Private_Data *pd, Eo_Callback_Description *cb)
{
- Eo_Callback_Description *itr, *pitr;
+ Eo_Callback_Description *itr, *pitr, *base;
- itr = pitr = pd->callbacks;
- if (pd->callbacks == cb)
- pd->callbacks = cb->next;
+ base = itr = pd->callbacks;
+ pitr = NULL;
for ( ; itr; )
{
{
pitr->next = titr->next;
}
+ else
+ {
+ /* If pitr is NULL, it means we need to update base. */
+ base = titr->next;
+ }
free(titr);
}
else
pitr = titr;
}
}
+
+ pd->callbacks = base;
}
/* Actually remove, doesn't care about walking list, or delete_me */