engine/source/scriptlib/List.c
//removes the current node and sets current to next, if applicable
removes the current node and sets current to next, if applicable
removes the current node and sets current to next if applicable
void List_Remove(List *list)
{
#ifdef DEBUG
    chklist((List *)list);
#endif
    Node *nptr;
#ifdef LIST_DEBUG
    printf("List_Remove %p\n", list);
#endif
    if (list->size == 0)
    {
        return;
    }
    else if (list->size == 1)
    {
#ifdef USE_STRING_HASHES
        List_RemoveHash(list, list->current);
#endif
        Node_Clear(list->current);
        free(list->current);
        list->first = list->current = list->last = NULL;
#ifdef USE_INDEX
        List_FreeIndices(list);
#endif
    }
    else
    {
#ifdef USE_INDEX
        if(list->mindices)
        {
            if (list->current != list->last)
            {
                List_FreeIndices(list);    
            }
            else
            {
                List_RemoveLastIndex(list);
            }
        }
#endif
        if(list->current->prev != NULL)
        {
            list->current->prev->next = list->current->next;
        }
        if(list->current->next)
        {
            list->current->next->prev = list->current->prev;
        }
        if (list->current == list->last)
        {
            nptr = list->current->prev;
        }
        else
        {
            nptr = list->current->next;
        }
#ifdef USE_STRING_HASHES
        List_RemoveHash(list, list->current);
#endif
        Node_Clear(list->current);
        free(list->current);
        if (list->current == list->last)
        {
            list->last = nptr;
        }
        if (list->current == list->first)
        {
            list->first = nptr;
        }
        list->current = nptr;
    }
    list->size--;
}
void List_Remove ( List * list ) { #ifdef DEBUG chklist ( ( List * ) list ) ; #endif Node * nptr ; #ifdef LIST_DEBUG printf ( " \n " , list ) ; #endif if ( list -> size == 0 ) { return ; } else if ( list -> size == 1 ) { #ifdef USE_STRING_HASHES List_RemoveHash ( list , list -> current ) ; #endif Node_Clear ( list -> current ) ; free ( list -> current ) ; list -> first = list -> current = list -> last = NULL ; #ifdef USE_INDEX List_FreeIndices ( list ) ; #endif } else { #ifdef USE_INDEX if ( list -> mindices ) { if ( list -> current != list -> last ) { List_FreeIndices ( list ) ; } else { List_RemoveLastIndex ( list ) ; } } #endif if ( list -> current -> prev != NULL ) { list -> current -> prev -> next = list -> current -> next ; } if ( list -> current -> next ) { list -> current -> next -> prev = list -> current -> prev ; } if ( list -> current == list -> last ) { nptr = list -> current -> prev ; } else { nptr = list -> current -> next ; } #ifdef USE_STRING_HASHES List_RemoveHash ( list , list -> current ) ; #endif Node_Clear ( list -> current ) ; free ( list -> current ) ; if ( list -> current == list -> last ) { list -> last = nptr ; } if ( list -> current == list -> first ) { list -> first = nptr ; } list -> current = nptr ; } list -> size -- ; }
removes the current node and sets current to next, if applicable
removes the current node and sets current to next if applicable
//OutputDebugString("Attempted to remove from empty list.\n"); // removing something before something else destroys our indices list.