42-archive/42-piscine-c/d11/ex11/ft_list_find.c
2016-08-25 20:50:28 +02:00

32 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_find.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/14 13:35:40 by jhalford #+# #+# */
/* Updated: 2016/08/14 13:36:48 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include "ft_list.h"
t_list *ft_list_find(
t_list *begin_list,
void *data_ref,
int (*cmp)())
{
t_list *list_ptr;
list_ptr = begin_list;
while (list_ptr)
{
if ((*cmp)(list_ptr->data, data_ref) == 0)
return (list_ptr);
list_ptr = list_ptr->next;
}
return (list_ptr);
}