repositories
/
TD_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Buildsystem: be more friendly with cygwin environment
[TD_C.git]
/
TP_11
/
exo2
/
lib
/
clist.c
diff --git
a/TP_11/exo2/lib/clist.c
b/TP_11/exo2/lib/clist.c
index 244a6877d31f111d79ea9aed02bbeb2eefdb186d..303115419a8e27dafa4286d8399c8a948260bf5f 100644
(file)
--- a/
TP_11/exo2/lib/clist.c
+++ b/
TP_11/exo2/lib/clist.c
@@
-34,10
+34,11
@@
link_t* list_prepend(link_t* head, int value) {
}
link_t* list_insert(link_t* head, unsigned index, int value) {
}
link_t* list_insert(link_t* head, unsigned index, int value) {
+ unsigned max_index = list_count(head);
if (index == 0) {
return list_prepend(head, value);
if (index == 0) {
return list_prepend(head, value);
- } else if (index ==
list_count(head)
) {
+ } else if (index ==
max_index
) {
return list_append(head, value);
} else {
link_t* link_insrt = list_new(value);
return list_append(head, value);
} else {
link_t* link_insrt = list_new(value);
@@
-58,7
+59,7
@@
link_t* list_delete(link_t* head, unsigned index) {
link_t* head_prev = NULL;
link_t* head_next = NULL;
link_t* head_ret = NULL;
link_t* head_prev = NULL;
link_t* head_next = NULL;
link_t* head_ret = NULL;
-
+
if (head == NULL) {
return NULL;
} else if (index == 0) {
if (head == NULL) {
return NULL;
} else if (index == 0) {
@@
-209,8
+210,8
@@
void list_display_values(link_t* head) {
printf("------Begin------\n");
while (head != NULL) {
printf("value at [%d]=%d\n", i, head->value);
printf("------Begin------\n");
while (head != NULL) {
printf("value at [%d]=%d\n", i, head->value);
- head = head->next;
- i++;
+
head = head->next;
+
i++;
}
printf("------End------\n");
}
}
printf("------End------\n");
}