From: Jerome Benoit Date: Fri, 3 Mar 2017 19:29:20 +0000 (+0100) Subject: TP 9 exo2: Better handling of special cases in list_delete() X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=abe54438847c1a491145a7719e43d19950732569;p=TD_C.git TP 9 exo2: Better handling of special cases in list_delete() Signed-off-by: Jerome Benoit --- diff --git a/TP_9/exo2/clist.c b/TP_9/exo2/clist.c index edc2964..9ebb348 100644 --- a/TP_9/exo2/clist.c +++ b/TP_9/exo2/clist.c @@ -57,7 +57,9 @@ link_t* list_delete(link_t* head, unsigned index) { link_t* head_next = NULL; link_t* head_ret = NULL; - if (index == 0) { + if (head == NULL) { + return NULL; + } else if (index == 0) { head_next = head->next; free(head); head = head_next;