Add RemoveCallback3 to match callback function and supply user function to determine if this callback should be deleted. Allows checking inside the userdata structure instead of just the address - needed for motor uninterest.

r1986 | dcl | 2007-05-25 16:15:15 +1000 (Fri, 25 May 2007) | 2 lines
This commit is contained in:
Douglas Clowes
2007-05-25 16:15:15 +10:00
parent 2d36c99ac8
commit efe6f72b43
2 changed files with 31 additions and 1 deletions

View File

@@ -230,7 +230,36 @@
iCurrent = LLDnodePtr2Next(self->iList);
}
return 1;
}
}
/*--------------------------------------------------------------------------*/
int RemoveCallback3(pICallBack self, SICSCallBack pFunc, int (*func)(const void* context, const void* pUserData), void *context)
{
CallBackItem sItem;
int iCurrent;
if(!CheckPointer(self))
{
return 0;
}
iCurrent = LLDnodePtr2First(self->iList);
while(iCurrent != 0)
{
LLDnodeDataTo(self->iList,&sItem);
if(sItem.pFunc == pFunc && func(context, sItem.pUserData) == 0)
{
if(sItem.pKill != NULL)
{
sItem.pKill(sItem.pUserData);
}
LLDnodeDelete(self->iList);
iCurrent = LLDnodePtr2First(self->iList);
continue;
}
iCurrent = LLDnodePtr2Next(self->iList);
}
return 1;
}
/*-------------------------------------------------------------------
a write function for the connection which writes to stdout
-------------------------------------------------------------------*/