/*------------------------------------------------------------------------------ * Empty a list of element. * All elements are freed. * @param list List to empty. ----------------------------------------------------------------------------*/ void SList_Empty(SList list) { SListNode node; if (list!=NULL) { node = list->first; while (node) { SListNode next = (SListNode) node->next; if (list->destroyElement) list->destroyElement (node->elem); node->elem = NULL; TtaFreeMemory (node); node = next; } list->first = list->last = NULL; } }
/*------------------------------------------------------------------------------ * Destroy an element. * Remove an element and destroy it. * @param list List from which remove the element. * @param node Node to remove. ----------------------------------------------------------------------------*/ void SList_DestroyElement (SList list, SListNode node) { ContainerElement elem = SList_RemoveElement(list, node); if (elem && list->destroyElement) list->destroyElement(elem); }