pic32/libraries/SoftPWMServo/SoftPWMServo.cpp
// Remove a channel from the linked list of channels
Remove a channel from the linked list of channels
Remove a channel from the linked list of channels
void Remove(uint32_t Channel)
{
    ChanType * ChanP = FirstChanP[InactiveBuffer];
    ChanType * LastChanP = FirstChanP[InactiveBuffer];
    while (ChanP != NULL)
    {
        if (ChanP == &Chan[InactiveBuffer][Channel])
        {
            if (ChanP == FirstChanP[InactiveBuffer])
            {
                FirstChanP[InactiveBuffer] = ChanP->NextChanP;
            }
            else
            {
                LastChanP->NextChanP = ChanP->NextChanP;
            }
            ChanP->NextChanP = NULL;
            break;
        }
        LastChanP = ChanP;
        ChanP = ChanP->NextChanP;
    }
}
void Remove ( uint32_t Channel ) { ChanType * ChanP = FirstChanP [ InactiveBuffer ] ; ChanType * LastChanP = FirstChanP [ InactiveBuffer ] ; while ( ChanP != NULL ) { if ( ChanP == & Chan [ InactiveBuffer ] [ Channel ] ) { if ( ChanP == FirstChanP [ InactiveBuffer ] ) { FirstChanP [ InactiveBuffer ] = ChanP -> NextChanP ; } else { LastChanP -> NextChanP = ChanP -> NextChanP ; } ChanP -> NextChanP = NULL ; break ; } LastChanP = ChanP ; ChanP = ChanP -> NextChanP ; } }
Remove a channel from the linked list of channels
Remove a channel from the linked list of channels
// Walk through the linked list, looking for our target // Is this element the one we're looking for? // Yup. So let's remove it from the linked list then // Are we on the first channel? // Yes, so change the first channel pointer instead // Nope, we're in the list. So change this element's previous pointer // And always zero this element's next pointer out // And we're done so bail // Advance our pointers by one element in the list