-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_insertarr.c
More file actions
35 lines (32 loc) · 1.25 KB
/
ft_insertarr.c
File metadata and controls
35 lines (32 loc) · 1.25 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_insertarr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: makbulut <makbulut@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/20 17:50:28 by makbulut #+# #+# */
/* Updated: 2022/09/05 13:53:19 by makbulut ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "minishell.h"
#include "42-Libft/libft.h"
void ft_insertarr(void ***arr, void *new, int index)
{
void **newarr;
int i;
int k;
newarr = ft_calloc(sizeof(void *), ft_arrlen((void **)*arr) + 2);
i = 0;
k = 0;
while (*arr && (*arr)[k])
{
if (k == index)
newarr[i++] = new;
newarr[i++] = (*arr)[k];
k++;
}
free(*arr);
*arr = newarr;
}