-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strtabcpy.c
executable file
·41 lines (38 loc) · 1.32 KB
/
ft_strtabcpy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtabcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <tseguier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/12/27 18:21:44 by tseguier #+# #+# */
/* Updated: 2014/03/27 18:42:40 by jcoignet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
char **ft_strtabcpy(char **strtab, int addsize)
{
int len;
char **newtab;
len = 0;
if (!strtab)
return (NULL);
while (strtab[len])
len++;
newtab = (char**)malloc(sizeof(char*) * (len + addsize + 1));
if (!newtab)
return (NULL);
--len;
while (len >= 0)
{
newtab[len] = ft_strdup(strtab[len]);
if (!newtab[len])
{
ft_strtabdel(&newtab);
return (NULL);
}
--len;
}
return (newtab);
}