ft_tabdup.c 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_tabdup.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2017/03/14 00:38:32 by bchanot #+# #+# */
  9. /* Updated: 2018/10/14 03:20:22 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. char **ft_tabdup(char **tabl)
  14. {
  15. size_t i;
  16. char **ret;
  17. if (!tabl)
  18. return (0);
  19. if (!(ret = (char **)ft_memalloc(sizeof(char *) * (ft_tablen(tabl) + 1))))
  20. return (NULL);
  21. i = -1;
  22. while (tabl[++i])
  23. ret[i] = ft_strdup(tabl[i]);
  24. ret[i] = 0;
  25. return (ret);
  26. }