static void test_11(void) { sSLList *l1; size_t oldFree; test_caseStart("Testing sll_removeFirst"); oldFree = heapspace(); l1 = sll_create(); sll_append(l1,(void*)4); sll_append(l1,(void*)3); sll_append(l1,(void*)2); test_assertSize(sll_length(l1),3); test_assertPtr(sll_removeFirst(l1),(void*)4); test_assertSize(sll_length(l1),2); test_assertPtr(sll_removeFirst(l1),(void*)3); test_assertSize(sll_length(l1),1); test_assertPtr(sll_removeFirst(l1),(void*)2); test_assertSize(sll_length(l1),0); test_assertPtr(sll_removeFirst(l1),NULL); sll_destroy(l1,false); test_assertSize(heapspace(),oldFree); test_caseSucceeded(); }
void sll_delete (sll_s ** pp_sll) { if (pp_sll && *pp_sll) { sll_first (*pp_sll); while ((*pp_sll)->list->next != NULL) { sll_removeNext (*pp_sll); } sll_removeFirst (*pp_sll); free ((*pp_sll)->list); (*pp_sll)->list = NULL; free (*pp_sll), *pp_sll = NULL; } }