- fixed bug in cleanCallbackList
This commit is contained in:
39
callback.c
39
callback.c
@ -135,37 +135,28 @@ static void markUserdata4Kill(pICallBack self, void *pData)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void cleanCallbackList(pICallBack self)
|
||||
{
|
||||
pCallBackItem toKill, current;
|
||||
pCallBackItem toKill, current, previous;
|
||||
|
||||
/*
|
||||
* killing at the head
|
||||
*/
|
||||
while (self->head != NULL && self->head->killFlag == 0) {
|
||||
toKill = self->head;
|
||||
self->head = toKill->next;
|
||||
if (toKill->pKill != NULL) {
|
||||
toKill->pKill(toKill->pUserData);
|
||||
}
|
||||
free(toKill);
|
||||
}
|
||||
|
||||
if (self->head == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* killing in the middle and the end
|
||||
*/
|
||||
previous = NULL;
|
||||
current = self->head;
|
||||
while (current->next != NULL) {
|
||||
if (current->next->killFlag == 1) {
|
||||
toKill = current->next;
|
||||
current->next = toKill->next;
|
||||
while (current != NULL) {
|
||||
if (current->killFlag == 1) {
|
||||
toKill = current;
|
||||
current = current->next;
|
||||
|
||||
/* update link from previous item or from head */
|
||||
if (previous == NULL) {
|
||||
self->head = current;
|
||||
} else {
|
||||
previous->next = current;
|
||||
}
|
||||
|
||||
if (toKill->pKill != NULL) {
|
||||
toKill->pKill(toKill->pUserData);
|
||||
}
|
||||
free(toKill);
|
||||
} else {
|
||||
previous = current;
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user