Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2023 |
3 |
|
|
** my_find_node |
4 |
|
|
** File description: |
5 |
|
|
** Finds a node in a linked list and return it |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "mylist.h" |
9 |
|
|
|
10 |
|
✗ |
linked_list_t *my_find_node(linked_list_t const *begin, void const *data_ref, |
11 |
|
|
int (*cmp) ()) |
12 |
|
|
{ |
13 |
|
✗ |
for (linked_list_t *tmp = (linked_list_t *)begin; tmp != NULL; tmp = |
14 |
|
|
tmp->next) { |
15 |
|
✗ |
if ((cmp == NULL && tmp->data == data_ref) |
16 |
|
✗ |
|| (cmp != NULL && cmp(tmp->data, data_ref) == 0)) |
17 |
|
✗ |
return tmp; |
18 |
|
|
} |
19 |
|
✗ |
return NULL; |
20 |
|
|
} |
21 |
|
|
|