diff options
| author | Tyge Løvset <[email protected]> | 2023-03-26 09:45:26 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-03-26 09:45:26 +0200 |
| commit | f2f9eaab3e347d04dfa98978e20fcdcdcb38c72d (patch) | |
| tree | 880f24fd38d4981e83fb4e33bdc240725fc22c75 /misc | |
| parent | eb85069b669e754836b9d4587ba03d3af1a5e975 (diff) | |
| download | STC-modified-f2f9eaab3e347d04dfa98978e20fcdcdcb38c72d.tar.gz STC-modified-f2f9eaab3e347d04dfa98978e20fcdcdcb38c72d.zip | |
Fixed bug/leak in intrusive.c example.
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/examples/intrusive.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/misc/examples/intrusive.c b/misc/examples/intrusive.c index 093cb36e..0d503575 100644 --- a/misc/examples/intrusive.c +++ b/misc/examples/intrusive.c @@ -24,11 +24,9 @@ int main() { List_sort(&list); printList(list); - puts("Remove odd numbers from list list"); - c_foreach (i, List, list) - if (*i.ref & 1) - List_unlink_after_node(&list, i.prev); - printList(list); + puts("Remove nodes from list"); + while (!List_empty(&list)) + c_free(List_unlink_after_node(&list, list.last)); - List_drop(&list); + printList(list); } |
