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:
edbb50f
)
TP_8 exo3: Properly free the memory on all elements of the linked list.
author
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Tue, 28 Feb 2017 14:28:06 +0000
(15:28 +0100)
committer
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Tue, 28 Feb 2017 14:28:06 +0000
(15:28 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP_8/exo3/exo3.c
patch
|
blob
|
blame
|
history
diff --git
a/TP_8/exo3/exo3.c
b/TP_8/exo3/exo3.c
index 6c2d6c542e57002d476eb7763eae10a6ac55d9af..2c433a5f90a7246ed3c3764167deea711528207e 100644
(file)
--- a/
TP_8/exo3/exo3.c
+++ b/
TP_8/exo3/exo3.c
@@
-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() {