/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_tabjoin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bchanot +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/23 01:28:42 by bchanot #+# #+# */ /* Updated: 2018/10/29 11:52:02 by bchanot ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char **ft_tabjoin(char **tabl, const char *const src) { char **tmp; size_t i; if (!tabl) { if (!(tmp = (char **)ft_memalloc(sizeof(char *) * 2))) return (NULL); tmp[1] = 0; tmp[0] = ft_strdup(src); } else { i = -1; if (!(tmp = (char **)ft_memalloc(sizeof(char *) * (ft_tablen(tabl) + 2)))) return (NULL); while (tabl[++i]) tmp[i] = ft_strdup(tabl[i]); tmp[i] = ft_strdup(src); tmp[i + 1] = 0; ft_memdel2((void ***)&tabl); } return (tmp); }