Browse Source

[enh] libft: add tabdel f(). free env.

Moul 3 years ago
parent
commit
0872d413d3
3 changed files with 31 additions and 0 deletions
  1. 1 0
      Makefile
  2. 1 0
      libft.h
  3. 29 0
      src/ft_tabdel.c

+ 1 - 0
Makefile

@@ -61,6 +61,7 @@ ft_strjoin.c \
 ft_strjoinf.c \
 ft_strsplit.c \
 ft_tabsize.c \
+ft_tabdel.c \
 ft_itoa.c \
 ft_itoa_base.c \
 ft_strtrim.c \

+ 1 - 0
libft.h

@@ -77,6 +77,7 @@ char				*ft_strjoinf(char const *s1, char const *s2, int p);
 char				*ft_strtrim(char const *s);
 char				**ft_strsplit(char const *s, char c);
 int					ft_tabsize(char **tab);
+void				ft_tabrdel(char **tabe);
 char				*ft_itoa(int n);
 char				*ft_itoa_base(int value, int base);
 void				ft_putchar(char c);

+ 29 - 0
src/ft_tabdel.c

@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   ft_tabdel.c                                        :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: mazimi <marvin@42.fr>                      +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2016/11/29 16:51:44 by mazimi            #+#    #+#             */
+/*   Updated: 2016/11/29 16:58:45 by mazimi           ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */
+
+#include "../libft.h"
+
+/*
+** free each lines of the chart
+** free global chart
+*/
+
+void	ft_tabdel(char **tabe)
+{
+	int		i;
+
+	i = -1;
+	while (tabe[++i] != NULL)
+		ft_strdel(&tabe[i]);
+	free(tabe);
+	tabe = NULL;
+}