-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_2d_int_array.c
36 lines (33 loc) · 1.43 KB
/
ft_2d_int_array.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_2d_int_array.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/08/07 23:07:22 by sgrindhe #+# #+# */
/* Updated: 2018/08/08 21:45:51 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_2d_int_array *ft_2d_int_array(unsigned int width, unsigned int height)
{
unsigned int i;
int **temp_array;
t_2d_int_array *s_result;
if (width == 0 || height == 0)
return (NULL);
temp_array = malloc(sizeof(int*) * width);
if (!temp_array)
return (NULL);
i = 0;
while (i < height)
{
temp_array[i++] = (int*)malloc(sizeof(int) * height);
}
s_result = malloc((sizeof(int*) * width) * (sizeof(int) * height));
s_result->two_dim_array = temp_array;
s_result->width = width;
s_result->height = height;
return (s_result);
}