#include "libft.h" int ft_lstinsert(t_list **lst, t_list *node, int index) { t_list *curr = *lst; t_list *prev = NULL; int i = 0; if (index < 0 || !node) return (-1); if (index == 0) { node->next = *lst; *lst = node; return (0); } while (curr && i < index) { prev = curr; curr = curr->next; i++; } if (i == index) { prev->next = node; node->next = curr; return 0; } return (-1); }