X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_8%2Fexo3%2Fexo3.c;h=2c433a5f90a7246ed3c3764167deea711528207e;hb=1c7a8fe964e67bfcdc3e6550d0a090e8686e8387;hp=18b065181cf5b65c6467b5e9c584ea65a5e2fe78;hpb=7c4bfcc0aacab351b7534e2e09ebd98239901db0;p=TD_C.git diff --git a/TP_8/exo3/exo3.c b/TP_8/exo3/exo3.c index 18b0651..2c433a5 100644 --- a/TP_8/exo3/exo3.c +++ b/TP_8/exo3/exo3.c @@ -45,7 +45,7 @@ unsigned list_count(link_t* head) { int list_get(link_t* head, unsigned index) { if (index < list_count(head)) { - for (int i = 0; i < index; i++) { + for (unsigned i = 0; i < index; i++) { head = head->next; } return head->value; @@ -55,7 +55,12 @@ int list_get(link_t* head, unsigned index) { } void list_clear(link_t* link) { - free(link); + + while (link != NULL) { + link_t* next_link = link; + free(link); + link = next_link; + } } int main() {