aboutsummaryrefslogtreecommitdiff
path: root/test_mini/libft/src/algo/ft_lfind.c
diff options
context:
space:
mode:
Diffstat (limited to 'test_mini/libft/src/algo/ft_lfind.c')
-rw-r--r--test_mini/libft/src/algo/ft_lfind.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test_mini/libft/src/algo/ft_lfind.c b/test_mini/libft/src/algo/ft_lfind.c
new file mode 100644
index 0000000..8538f50
--- /dev/null
+++ b/test_mini/libft/src/algo/ft_lfind.c
@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_lfind.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 05:49:19 by cacharle #+# #+# */
+/* Updated: 2020/02/10 05:58:19 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_algo.h"
+
+void *ft_lfind(const void *base, size_t *nelp, size_t width,
+ t_ftsearch_const *consts)
+{
+ size_t i;
+
+ i = 0;
+ while (i < *nelp)
+ {
+ if ((consts->compar)(consts->key, base + i * width) == 0)
+ return ((void*)base + i * width);
+ i++;
+ }
+ return (NULL);
+}