-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_malloc_2d.c
28 lines (25 loc) · 1.17 KB
/
ft_malloc_2d.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_malloc_2d.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smonroe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/20 22:05:16 by smonroe #+# #+# */
/* Updated: 2018/04/23 14:57:10 by smonroe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char **ft_malloc_2d(size_t col, size_t row)
{
char **array;
if (!(array = (char **)malloc(sizeof(char *) * col + 1)))
return (NULL);
while (col > 0)
{
if (!(array[col--] = (char *)malloc(sizeof(char) * row + 1)))
return (NULL);
ft_bzero(array[col], row);
}
return (array);
}