diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-11-24 04:51:55 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-11-24 04:51:55 +0100 |
| commit | 997cb1c39c603512b7db760e9537c39ea3c68a38 (patch) | |
| tree | b09df18114389b331a8b07254c78f881afb222b5 /functions_reference/ref_ft_list_remove_if.c | |
| parent | 5a47d63887a0878243b17799b19c4a0f76d3756d (diff) | |
| download | libasm_test-997cb1c39c603512b7db760e9537c39ea3c68a38.tar.gz libasm_test-997cb1c39c603512b7db760e9537c39ea3c68a38.tar.bz2 libasm_test-997cb1c39c603512b7db760e9537c39ea3c68a38.zip | |
Added reference bonus functions to test against assembly one
Diffstat (limited to 'functions_reference/ref_ft_list_remove_if.c')
| -rw-r--r-- | functions_reference/ref_ft_list_remove_if.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/functions_reference/ref_ft_list_remove_if.c b/functions_reference/ref_ft_list_remove_if.c new file mode 100644 index 0000000..8b55da1 --- /dev/null +++ b/functions_reference/ref_ft_list_remove_if.c @@ -0,0 +1,21 @@ +#include "libasm_test.h" + +void +ref_ft_list_remove_if(t_list **begin_list, void *data_ref, + int (*cmp)(), void (*free_fct)(void *)) +{ + t_list *saved_next; + + if (begin_list == NULL || *begin_list == NULL) + return ; + if (cmp(&(*begin_list)->val, data_ref) != 0) + { + ref_ft_list_remove_if(&(*begin_list)->next, data_ref, cmp, free_fct); + return ; + } + saved_next = (*begin_list)->next; + free_fct((*begin_list)->val); + free(*begin_list); + *begin_list = saved_next; + ref_ft_list_remove_if(begin_list, data_ref, cmp, free_fct); +} |
