repositories
/
TD_C.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1d97ec3
)
TP 9 exo2: Better handling of special cases in list_delete()
author
Jerome Benoit
<jerome.benoit@sap.com>
Fri, 3 Mar 2017 19:29:20 +0000
(20:29 +0100)
committer
Jerome Benoit
<jerome.benoit@sap.com>
Fri, 3 Mar 2017 19:29:20 +0000
(20:29 +0100)
Signed-off-by: Jerome Benoit <jerome.benoit@sap.com>
TP_9/exo2/clist.c
patch
|
blob
|
blame
|
history
diff --git
a/TP_9/exo2/clist.c
b/TP_9/exo2/clist.c
index edc296473e54c3910d0d4ea5fe3c3058aaf2913a..9ebb34817e5982fa3b3131e388d01b320f6a3a70 100644
(file)
--- 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;